// 出院结算

import React from 'react';
import { Select, Input, Row, Col, Button, Spin, Divider, message, Icon, Form, DatePicker, Table, Tabs, Modal, Card, Switch } from 'antd';
import { $http } from 'containers/config/https';
import { Keup, ArraySome } from '../../../tools/index';
import HopNumber from './component/HopNumber'
import ListOfHospitalizationExpenses from './ListOfHospitalizationExpenses'
import PatientAccountManagement from './PatientAccountManagement.jsx';
import SplitBills from '../SplitBills'
import { $loadTemplate } from '../../lodop/Common/Print.js';
import $ from 'pages/workstation/component/js/jquery-3.2.1.min.js';
import './style/index.less'
import store from 'store';
import ReadCard from '../../../components/readcard/ReadCard';
import RangeDatePicker from 'components/rangePicker/index';
import CommonPagination from 'components/pagination/index';
import ColumnAuthoritysModel from 'pages/columnAuthority/ColumnAuthoritysModel';
import { INSUYBUtil } from '../../../tools/index';
import INSURegister from 'pages/Cashier/INSURegisterInsu.jsx';
import { Util } from 'tools/index';
import PublicModalTable from 'pages/common/PublicModalTable';
import { $loopPrint } from '../../lodop/Common/Print';
import IframeModal from 'pages/common/IframeModal';
// 组件const
const { TabPane } = Tabs;
const { Option } = Select;
const { RangePicker } = DatePicker;
const dateFormat = 'YYYY-MM-DD' || undefined;
const { Search } = Input;
const icon_name = require('./image/img/icon_name.png');
const icon_gender = require('./image/img/icon_gender.png');
const icon_expense = require('./image/img/icon_expense.png');
const icon_icon = require('./image/img/icon_icon.png');
const infoModal = Modal.info;
const EditableContext = React.createContext();

class EditableCell extends React.Component {
    getInput = () => {
        if (this.props.inputType === 'select') {
            return <Select style={{ width: '80%' }} onSelect={(event) => { this.props.source.paywselect(event) }} >
                {this.props.option}
            </Select>;
        }
        return <Input style={{ width: '80%' }} onChange={(event) => { this.props.source.paymoney(event) }} onFocus={(event) => { this.props.source.paymoneyonfocus(event) }} />;

    };

    renderCell = ({ getFieldDecorator }) => {
        const {
            editing,
            dataIndex,
            title,
            option,
            inputType,
            record,
            index,
            children,
            ...restProps
        } = this.props;
        return (
            <td {...restProps}>
                {editing ? (
                    <Form.Item style={{ margin: 0 }}>
                        {getFieldDecorator(dataIndex, {
                            rules: [
                                {
                                    required: true,
                                    message: `${title + (JSON.parse(window.sessionStorage.userData).language == 'EN' ? ' Can not be empty!' : '不能为空!')}`,
                                },
                            ],
                            initialValue: record[dataIndex],
                        })(this.getInput())}
                    </Form.Item>
                ) : (
                    children
                )}
            </td>
        );
    };

    render() {
        return <EditableContext.Consumer>{this.renderCell}</EditableContext.Consumer>;
    }
}

class DischargeSettlement extends React.Component {
    constructor(props) {
        super(props)
        let userData = JSON.parse(sessionStorage.getItem('userData'));
        this.state = {
            userInfo: {}, // 用户数据
            dataTableTop: [], // table数据 上列表table
            dataTable1: [], // table数据 主列表table
            dataTable2: [], // table数据 折扣记账系数配置列表
            dataTable3: [], // table数据 不属于折扣内明细

            selectListData1: [],
            selectListData2: [],
            selectListData3: [],
            payWListData: [], // table数据 支付方式列表
            paywamtData: '',
            payWListkey: 10,
            totalTop: 0,
            pageTop: 1,
            pageSizeTop: 100,
            // 表格数据总条数1
            total1: 0,
            page1: 1,
            pageSize1: 10,
            StartDateTop: undefined,  // //开始日期
            EndDateTop: undefined,  // //结束日期
            StartDate1: undefined,  // //
            EndDate1: undefined,  // //结束日期
            cardType: '', // 卡类型
            cardTypeData: [], // 卡类型
            cardNo: '', // 卡号
            patNo: '',
            select1: '',
            select2: '',
            select3: '',
            nameNo: '',
            execID: [],
            ordID: '',
            modalShow: false,
            columnsTop: [],
            ipPayWListTop: [],
            columns1: [],
            selectedRowKeys: [],
            money: {},
            bqType: '',
            bednumber: '',
            jsType: '',
            chargeStatus: 'B',
            bqData: [],
            bedData: [],
            jsTypeData: [],
            time1: '2',
            allMoney: 0,
            accSubStatus: {}, //账户状态
            userPayData: {}, //账户状态
            patBillID: '',
            paras: {},
            subTypeFeeArr: [],
            otherPayData: [], //其他付款方式:
            sysConfigIP: '',
            payType: '', // 付款方式

            otherPay: '', //其他支付方式
            otherPayDis: false, //其他支付方式不可选
            otherPayMoney: '0.00', // 其他支付金额
            cashInCashVal: '0.00', // 实收现金
            payAccIPAmt: '0.00',	//住院结算参与账户的金额
            selectedRows: [],
            recordID: '',
            ipInsuType: '',
            visible: false,
            visibleMoney: false,
            visibleMoney2: false,
            leftAmt: '',
            patAmt: '',
            accAmtBalance: '',
            accpayBalance: '',
            leftAmtSur: '',
            zeroPay: '0.00', // 找零
            disBtton1: true,
            disBtton2: true,
            disBtton3: true,
            disBtton4: true,
            disBtton5: true,
            disBtton6: true,
            disBtton7: true,
            accDepositIDinfo: '',
            readModeI: true,
            readModeR: true,
            recordData: {},
            languageData: {}, // 国际化语言包
            language: {},   // 国际化语言
            languageCode: JSON.parse(window.sessionStorage.userData).language, // 国际化语言标识
            ColumnAuthority: '',
            INSURegisterVisable: false,
            contextMenuvisible: false,
            disXJ: false,
            comepnCode: '2101',
            xnhBCTYPE: '',
            ifsubmit: '0',
            YBPatDivdata: [],
            comepnCodeList: [],
            xnhBCTYPEList: [],

            traumaFlag:'N',         //外伤标识
            thirdFlag:'N',          //第三方标识
            insuMdHosType:'',//住院类型

            insuPayID: '',
            ybPayDivdata: '',
            InsuIPPayButton: '0',
            InsuIPPayModalvisible: false,
            secondsToGo: 0,
            trialflag: '',
            editingKey: '',
            xnhtreatCodeist: [],
            treatCode: '',
            icdAllNoEList: [],
            icdAllNo: '',       // 医保诊断code
            modalPageSize: 10,
            modalPage: 1,
            modalTotal: 0,
            INSUICDDesc: '',    // 医保诊断描述
            searchCode: '',
            ifNeedTreatWay: 'N',     // 治疗方式是否需要必填
            userData: userData,
            admReasonCode: '',
            surplusamt: 0,
            activeKey: '0', //Tab选择
            readCardType: 'read',
            ybCardFlag: 'N',       // 异地医保是否用卡余额结算
            QCCode: "",
            QCCodeShow: false,
            patMedicalNo: '',//病案号
            certType: "02",    //就诊凭证类型
            certNo: "",   //就诊凭证编号
            middleSettleFlag: 'N',     //中途结算
            userAccFlag:'Y',        //个人账户标志
        }

        this.myRef1 = React.createRef();
        this.myRef2 = React.createRef();
        this.myRef3 = React.createRef();
        this.myRef4 = React.createRef();
        this.myRef5 = React.createRef();
        this.myRef6 = React.createRef();
        this.refHandleOK = React.createRef();


        this.columns2 = [
            {
                title: '金额*规格',
                dataIndex: 'invNo',
                key: '1',
                align: "center",
                width: 200,
            }, {
                title: '支付方式',
                dataIndex: 'patBillCUnitPrice',
                key: '2',
                align: "center",
                width: 100,
            },
        ]
        this.modalColumns = [{
            title: 'ICD诊断代码',
            dataIndex: 'code',
            key: 'code'
        }, {
            title: 'ICD诊断描述',
            dataIndex: 'descripts',
            key: 'descripts'
        }]


    }
    componentDidMount() {
        this.cardTypeList() //卡类型
        this.initJuris() //权限
        this.jsList() //结算
        this.bqList() //病区
        this.tableList("IPPayBillList", "IPPayBillList");
        this.tableList("IPAdmList", "IPAdmList");
        this.tableList("IPPayWList", "IPPayWList");
        this.ordList1() //国际化
        this.dataTableTopData() // 查询
        document.addEventListener('click', this.handleClick)
        this.loadGoldTaxMessage()
    }

    //调用金税，获取库存信息
    loadGoldTaxMessage() {
        let that = this
        var source = encodeURIComponent("{ fpzl: 2 }")
        var dllInput = 'SID=0\&\&\&\SIDParam=' + source//JSON.stringify({ "SID": "0", "SIDParam": source })
        var dllPath = 'JSInv/prykjsapplication.dll'
        var className = 'prykjsapplication.JSHelper'
        var funcName = 'GetJSData'
        let data = 'input={"inputDir":"' + dllPath + '","clsName":"' + className + '","funcName":"' + funcName + '","dllInput":"' + dllInput + '"}'
        if (typeof (CefSharp) != "undefined") {   // 新元素定制浏览器
            // dllInput.path = "1";
            CefSharp.BindObjectAsync("xysCefToJavaScripts");
            setTimeout(() => {
                xysCefToJavaScripts.driveLocalHardware(JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput })).then((returnVale) => {
                    var res = JSON.parse(returnVale);
                    if (res.resultCode == '0') {
                        var source = JSON.parse(decodeURIComponent(res.result))
                        if (source && source.ENCMSG.invStock == 0) {
                            that.setState({
                                disBtn: true
                            })
                        }
                    }
                })
            }, 100);
        } else {
            $.getJSON("http://127.0.0.1:62534/XYSWCFService/DynamicLoadingDLL?JsonCallback=?", {
                input: JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput })
            },
                function (data) {
                    var res = JSON.parse(data);
                    if (res.resultCode == '0') {
                        var source = JSON.parse(decodeURIComponent(res.result))
                        if (source && source.ENCMSG.invStock == 0) {
                            that.setState({
                                disBtn: true
                            })
                        }
                    }
                    // alert(vData);
                });
        }
    }

    //获取金税开票信息
    loadInvoiceMessage() {
        var params = {
            params: [{
                userID: this.state.userData.userID,
                recordID: [this.state.compleRecordIDinfo]
            }]
        }
        $http.post('urlADS', this, {
            code: "05210077",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    var source = res.result;
                    if (!Util.isEmpty(source)) {
                        source['listed'] = (source.listed == 'true' ? true : false)
                    }
                    this.setState({
                        invoiceSource: source
                    }, () => {
                        if (this.state.userData && this.state.userData.hospCode === "H19") {
                            source && source.invoiceFileUrl ? window.open(source.invoiceFileUrl) : "";
                        } else {
                            this.loadInvoiceSource()//获取发票开具信息
                        }
                    })
                }
            }
        });
    }

    loadInvoiceSource() {
        let that = this
        var source = encodeURIComponent(JSON.stringify(that.state.invoiceSource))
        var dllInput = 'SID=1\&\&\&\SIDParam=' + source//JSON.stringify({ "SID": "0", "SIDParam": source })
        if (typeof (CefSharp) != "undefined") {   // 新元素定制浏览器
            // dllInput.path = "1";
            CefSharp.BindObjectAsync("xysCefToJavaScripts");
            setTimeout(() => {
                xysCefToJavaScripts.driveLocalHardware(JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput })).then((returnVale) => {
                    var res = JSON.parse(returnVale);
                    if (res.resultCode == '0') {
                        var source = JSON.parse(decodeURIComponent(res.result))
                        that.setState({
                            fpSource: source ? source.ENCMSG : ''
                        }, () => {
                            that.saveInviceMessage()
                        })

                    }
                })
            }, 100);
        } else {
            $.getJSON("http://127.0.0.1:62534/XYSWCFService/DynamicLoadingDLL?JsonCallback=?", {
                input: JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput })
            },
                function (data) {
                    var res = JSON.parse(data);
                    if (res.resultCode == '0') {
                        var source = JSON.parse(decodeURIComponent(res.result))
                        that.setState({
                            fpSource: source ? source.ENCMSG : ''
                        }, () => {
                            that.saveInviceMessage()
                        })

                    }
                    // alert(vData);
                });
        }
    }

    //保存金税信息
    saveInviceMessage() {
        var params = {
            params: [{
                recordID: [this.state.compleRecordIDinfo],
                ...this.state.fpSource
            }]
        }
        $http.post('urlADS', this, {
            code: "05210078",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.printButtont()
                    // this.loadPrintGoldTax()
                }
            }
        });
    }

    printButtont = () => {
        var data = {
            recordIDArr: [this.state.compleRecordIDinfo],
            params: [{
                userID: JSON.parse(window.sessionStorage.ipConfig).userID,             //收费员
                paywIDinfo: '',//个人自付支付方式数据(不包括    医保) ID^金额^合作单位ID_$c(2)_ID^金额^合作单位ID
                accmID: '',//账户ID
                IfPayInvMode: 'N',//集中打印发票是否重新计费支付方式（集中打印是医保结算也是重新计算支付方式）Y 是,N 否
                ifDirectPrint: 'N', //是否缴费直接打印标志
                groupID: JSON.parse(window.sessionStorage.userData).groupID,//登录安全组
                locID: JSON.parse(window.sessionStorage.userData).locID,//登录科室
                hospID: JSON.parse(window.sessionStorage.userData).hospID, //医院id //登录医院
                ip: JSON.parse(window.sessionStorage.ipConfig).ipv4,
                invNo: this.state.fpSource ? this.state.fpSource.fphm : ''//金税发票号码
            }]
        }

        $http.post('urlADS', this, {
            code: "05210034",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    this.setState({
                        invIDSt: res.invIDStr
                    }, () => {
                        this.loadPrintGoldTax()//金税打印
                    })
                }
            }
        });
    }

    loadPrintGoldTax() {
        let that = this
        var data = {
            'fpzl': 2,
            'fphm': this.state.fpSource ? this.state.fpSource.fphm : '',//金税发票号码
            'fpdm': this.state.fpSource ? this.state.fpSource.fpdm : '',//金税发票代码
            'showPrintDlg': 0
        }
        var source = encodeURIComponent(JSON.stringify(data))
        var dllInput = 'SID=2\&\&\&\SIDParam=' + source//JSON.stringify({ "SID": "0", "SIDParam": source })
        if (typeof (CefSharp) != "undefined") {   // 新元素定制浏览器
            // dllInput.path = "1";
            CefSharp.BindObjectAsync("xysCefToJavaScripts");
            setTimeout(() => {
                xysCefToJavaScripts.driveLocalHardware(JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput })).then((returnVale) => {
                    var res = JSON.parse(returnVale);
                    if (res.resultCode == '0') {
                        message.success('打印成功！')
                        that.loadGoldTaxMessage()
                        this.dataTableTopData();
                    }
                })
            }, 100);
        } else {
            $.getJSON("http://127.0.0.1:62534/XYSWCFService/DynamicLoadingDLL?JsonCallback=?", {
                input: JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput })
            },
                function (data) {
                    var res = JSON.parse(data);
                    if (res.resultCode == '0') {
                        message.success('打印成功！')
                        that.loadGoldTaxMessage()
                        this.dataTableTopData();
                    }
                    // alert(vData);
                });
        }
    }

    // 鼠标单击事件，当鼠标在任何地方单击时，设置菜单不显示
    handleClick = () => {
        const { contextMenuvisible } = this.state
        if (contextMenuvisible) {
            this.setState({ contextMenuvisible: false })
        }
    };
    componentWillUnmount() {
        document.removeEventListener('click', this.handleClick)
        // 组件销毁前将静止让setState修改state的状态
        this.setState = (state, callback) => { return; }
    }

    onColumnRef = (ref) => {
        this.columnRef = ref;
    }
    onPatAccManagement = (ref) => {
        this.patAccManagementChild = ref;
    }
    historyModal = () => {
        this.setState({
            modalShow: true,
        });
    }

    // 费用类型table
    ordList1 = () => {
        let data = {
            params: [{
                "reactCode": ["DischargeSettlement"],
                "compontName": "DischargeSettlement",
                "type": "C"

            }]
        }
        $http.post('urlS', this, {
            code: "01040073",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    this.setState({
                        languageData: res.result.language || {},  // 国际化语言包
                    }, () => {
                        this.LanCNEN(this.state.languageCode)
                    })
                }
            }
        });
    }

    LanCNEN = (code) => {
        let { languageData } = this.state
        this.setState({
            language: languageData[code]
        })
    }

    // 权限
    initJuris = () => {
        var data = {
            params: [{
                logonHospID: JSON.parse(window.sessionStorage.userData).hospID, //医院id
                logonGroupID: JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                logonUserID: JSON.parse(window.sessionStorage.userData).userID, //人员id
                invTypeCode: 'I'  // 类型
            }]
        }
        $http.post('urlS', this, {
            code: "05210001",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {


                    this.setState({
                        otherPayData: res.groupConfig.HBOPConfigPaymode[0].IPCharge || [],  // 其他付款方式
                        payType: res.groupConfig.HBOPConfigPaymode[0].IPCharge[0].paywID || '',
                        otherPay: res.groupConfig.HBOPConfigPaymode[0].IPCharge[1].paywID || '',
                    });


                }
            }
        });
    }

    clearnUserPayData = () => {
        this.setState({
            userPayData: {}, //账户状态
            cashInCashVal: '0.00', // 实收现金
            payAccIPAmt: '0.00',	//住院结算参与账户的金额
            otherPayDis: false, //其他支付方式不可选
            otherPayMoney: '0.00', // 其他支付金额
            disBtton1: true,
            disBtton2: true,
            disBtton3: true,
            disBtton4: true,
            disBtton5: true,
            disBtton6: true,
            disBtton7: true,
            accDepositIDinfo: '',
            subTypeFeeArr: [],
            INSURegisterVisable: false,
            disXJ: false,
            comepnCode: '2101',
            xnhBCTYPE: '',
            ifsubmit: '0',
            YBPatDivdata: [],
            comepnCodeList: [],
            xnhBCTYPEList: [],
            insuPayID: '',
            ybPayDivdata: '',
            InsuIPPayButton: '0',
            InsuIPPayModalvisible: false,
            trialflag: '',
            xnhtreatCodeist: [],
            treatCode: '',
            icdAllNoEList: [],
            icdAllNo: '',
            ifNeedTreatWay: 'N',     // 治疗方式是否需要必填
            surplusamt: 0,
        })
    }

    clearn = () => {
        this.setState({
            userInfo: {}, // 用户数据
            dataTableTop: [], // table数据 上列表table
            dataTable1: [], // table数据 主列表table
            dataTable2: [], // table数据 折扣记账系数配置列表
            dataTable3: [], // table数据 不属于折扣内明细
            selectListData1: [],
            selectListData2: [],
            selectListData3: [],
            totalTop: 0,
            pageTop: 1,
            pageSizeTop: 100,
            // 表格数据总条数1
            total1: 0,
            page1: 1,
            pageSize1: 10,
            StartDateTop: undefined,  // //开始日期
            EndDateTop: undefined,  // //结束日期
            StartDate1: undefined,  // //开始日期
            EndDate1: undefined,  // //结束日期

            cardNo: '', // 卡号
            patNo: '',
            select1: '',
            select2: '',
            select3: '',
            nameNo: '',
            execID: [],
            ordID: '',
            modalShow: false,
            selectedRowKeys: [],
            money: {},
            bqType: '',
            bednumber: '',
            jsType: '',
            chargeStatus: 'B',
            time1: '2',
            allMoney: 0,
            accSubStatus: {}, //账户状态
            userPayData: {}, //账户状态
            patBillID: '',
            subTypeFeeArr: [],
            cashInCashVal: '0.00', // 实收现金
            payAccIPAmt: '0.00',	//住院结算参与账户的金额
            otherPayDis: false, //其他支付方式不可选
            otherPayMoney: '0.00', // 其他支付金额
            selectedRows: [],
            recordID: '',
            ipInsuType: '',
            visible: false,
            visibleMoney: false,
            visibleMoney2: false,
            leftAmt: '',
            patAmt: '',
            payWListData: [],
            paywamtData: '',
            payWListkey: 10,
            accAmtBalance: '',
            leftAmtSur: '',
            disBtton1: true,
            disBtton2: true,
            disBtton3: true,
            disBtton4: true,
            disBtton5: true,
            disBtton6: true,
            disBtton7: true,
            accDepositIDinfo: '',
            readModeI: true,
            readModeR: true,
            INSURegisterVisable: false,
            comepnCode: '2101',
            xnhBCTYPE: '',
            ifsubmit: '0',
            YBPatDivdata: [],
            comepnCodeList: [],
            xnhBCTYPEList: [],
            insuPayID: '',
            ybPayDivdata: '',
            InsuIPPayButton: '0',
            InsuIPPayModalvisible: false,
            trialflag: '',
            xnhtreatCodeist: [],
            treatCode: '',
            icdAllNoEList: [],
            icdAllNo: '',
            ifNeedTreatWay: 'N',     // 治疗方式是否需要必填
            surplusamt: 0,
        })
    }

    // 数据配置
    tableList = (reactCode, compontName) => {
        var data = {
            params: [{
                "reactCode": [reactCode],
                "compontName": compontName,
                "type": "C"
            }]
        }

        $http.post('urlS', this, {
            code: "01040073",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    let resC = res.result.C
                    let { languageCode } = this.state

                    for (var i = 0; i < resC.length; i++) {
                        resC[i].key = i;
                    }

                    if (languageCode === "EN") {
                        resC.map((item, i) => {
                            item.title = item.enDescripts
                        })
                    }

                    if (languageCode === "CN") {
                        resC.map((item, i) => {
                            item.title = item.descripts
                        })
                    }
                    let arr = res.result && resC.length > 0 ? JSON.parse(JSON.stringify(resC)).map(item => {
                        return {
                            align: item.align,
                            widthNum: parseInt(item.width),
                            width: item.width,
                            dataIndex: item.dataIndex,
                            title: <div onDoubleClick={() => this.setState({ ColumnAuthority: compontName }, () => this.columnRef.onOpenModel())}>{item.title}</div>,
                            display: item.display,
                            key: item.seqNo
                        }
                    }) : '';

                    let filterArr = arr.filter(function (item) { return item.display === 'Y' });

                    if (compontName === 'IPPayBillList') {
                        this.setState({
                            columns1: filterArr, // 费用类型table
                        })
                    } else if (compontName === 'IPAdmList') {
                        this.setState({
                            columnsTop: filterArr, // 费用类型table
                        })
                    } else if (compontName === 'IPPayWList') {
                        let columns = [
                            {
                                title: '支付方式',
                                dataIndex: 'payWDesc',
                                editable: true,
                                width: '150px',
                                align: 'center'
                            },
                            {
                                title: '金额',
                                dataIndex: 'payWamt',
                                editable: true,
                                width: '150px',
                                align: 'center'
                            },
                            {
                                dataIndex: 'operation',
                                width: '20px',
                                align: 'center',
                                render: (text, record) => {
                                    const { editingKey } = this.state;
                                    const editable = this.isEditing(record);
                                    return (
                                        <span className="span" style={{ color: 'rgba(240,65,52,1)' }} onClick={() => this.handleDelete(record)}>X</span>
                                    );
                                },
                            },
                        ];
                        this.setState({
                            ipPayWListTop: columns, // 费用类型table
                        })
                    }

                }
            }
        });
    }
    // 新增表格数据
    handleAddTableData = () => {
        this.props.form.resetFields();
        const { payWListkey, payWListData } = this.state;
        let leg = payWListkey + 1;
        this.setState({
            payWListkey: leg,
        })
        let arr = [];
        const newData = {
            key: leg,
            payWID: '',
            payWCode: '',
            payWDesc: '',
            payWamt: ""
        };
        arr.push(newData)
        this.setState({
            payWListData: payWListData && payWListData.length > 0 ? [...payWListData, newData] : arr,
            editingKey: leg
        });
        this.checkpayMoneySurplus()
    }

    // 本地删除数据
    handleDelete = (rowData) => {
        if (this.state.payWListData.length === 1) {
            for (var i = 0; i < this.state.payWListData.length; i++) {
                if (this.state.payWListData[i].key === rowData.key) {
                    this.state.payWListData[i].payWID = this.state.otherPayData[0].paywID
                    this.state.payWListData[i].payWCode = this.state.otherPayData[0].paywCode
                    this.state.payWListData[i].payWDesc = this.state.otherPayData[0].paywDesc
                    this.state.payWListData[i].payWamt = ""
                    this.setState({ payWListData: this.state.payWListData });
                }
            }
        } else {
            const payWListData = JSON.parse(JSON.stringify(this.state.payWListData));
            this.setState({ payWListData: payWListData.filter(item => item.key !== rowData.key) });
        }
        this.checkpayMoneySurplus()
    }
    // 数据配置
    columns1(resC) {

        let { languageCode } = this.state
        for (var i = 0; i < resC.length; i++) {
            resC[i].key = i;
        }
        if (languageCode === "EN") {
            resC.map((item, i) => {
                item.title = item.enDescripts
            })
        }

        if (languageCode === "CN") {
            resC.map((item, i) => {
                item.title = item.descripts
            })
        }

        this.setState({
            columns1: resC, // 费用类型table
        });
    }

    // 数据配置
    columnsTop(resC) {

        let { languageCode } = this.state
        for (var i = 0; i < resC.length; i++) {
            resC[i].key = i;
        }
        if (languageCode === "EN") {
            resC.map((item, i) => {
                item.title = item.enDescripts
            })
        }

        if (languageCode === "CN") {
            resC.map((item, i) => {
                item.title = item.descripts
            })
        }

        this.setState({
            columnsTop: resC, // 费用类型table
        });
    }


    //卡类型
    cardTypeList = () => {
        var data = {
            params: [{
                hospID: JSON.parse(window.sessionStorage.userData).hospID, //医院id
            }]
        }

        $http.post('urlS', this, {
            code: "01040059",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    let cardDeffault = res.cardType.filter((item) => {
                        return item.defaultFlag === 'Y';
                    })
                    this.setState({
                        cardType: cardDeffault[0].id, // 默认卡
                        cardTypeData: res.cardType,  // 用户数据
                    }, () => {
                        this.CardTypeChange(this.state.cardType)
                    });
                }
            }
        });
    }

    //1.1.49.住院费用明细相关下拉框（病区）
    bqList = () => {
        var data = {
            params: [{
                "hospID": JSON.parse(window.sessionStorage.userData).hospID || '', //医院id
                "type": "W",
                "status": "1",
            }]
        }

        $http.post('urlS', this, {
            code: "04020008",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {

                    this.setState({
                        bqData: res.result.Data || [], // 数据
                    });
                }
            }
        });
    }
    //查询床位
    BedChange = (locID) => {
        let data = {
            params: [{
                locID: locID,
            }]
        }
        $http.post('urlS', this, {
            code: "01050021",
            data: data,
            success: function (res) {
                if (+res.errorCode === 0) {
                    this.setState({ bedData: res.result.Data })
                }
            }
        })
    }
    // 查询条件 --- 床位
    bednum = (e) => {
        this.setState({ bednumber: e });
    }
    Selectbednum = (e) => {
        this.setState({ bednumber: e }, () => this.dataTableTopData());
    }
    //1.1.49.住院费用明细相关下拉框（结算）
    jsList = () => {
        var data = {
            params: [{
                "hospID": JSON.parse(window.sessionStorage.userData).hospID || '', //医院id
            }]
        }

        $http.post('urlS', this, {
            code: "05100129",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {

                    this.setState({
                        jsTypeData: res.data || [], // 数据
                    });
                }
            }
        });
    }

    changereadCardType = (e) => {
        this.setState({ readCardType: e });
    }


    // 回车查询登记号
    patNodownE = (e, type) => {
        if (e.keyCode === 13) {
            this.searchUser(type)
        }
    }


    // 读卡 --- 根据卡号取病人信息
    handleReadCard = (value, event) => {
        let { readModeI, readModeR, cardType } = this.state
        if (event.keyCode) {
            if (readModeI) {
                this.searchUser('cardNo'); // 重新调用查询接口
            }
            return false
        }
        if (readModeR) {
            this.readCard.ReadCard(cardType, "R", (json) => {
                let patNo = json && json.patInfo ? json.patInfo.patNo : ''
                this.setState({ patNo , cardNo: json.cardNo }, () => {

                    //this.searchUser('cardNo'); // 重新调用查询接口
                    if (patNo)
                    {
                        this.searchUser('patNo'); // 重新调用查询接口
                    }else{
                        this.searchUser('cardNo'); // 重新调用查询接口
                    }
                })
            })
        }

    }


    // 读卡
    searchUser = (type, dataTableNo) => {
        var data;
        let { cardType, cardNo, patNo, cardTypeData } = this.state
        if (!type) {   // 查询全部
            data = {
                params: [{
                    "number": patNo || '', // 登记号/身份证号
                    "cardTypeID": cardType,   //卡类型id
                    "cardNo": cardNo,    //卡号
                }]
            }
        }

        if (type === 'patNo') {
            data = {
                params: [{
                    "number": patNo || '', // 登记号/身份证号
                    "cardTypeID": "",   //卡类型id
                    "cardNo": "",    //卡号
                }]
            }

            if (patNo === '') {
                return false
            }
        }

        if (type === 'cardNo') {
            data = {
                params: [{
                    "number": '', // 登记号/身份证号
                    "cardTypeID": cardType || '',     //卡类型id
                    "cardNo": cardNo || '', //卡号
                }]
            }

            if (cardNo === '') {
                return false
            }
            if (cardType === '') {
                message.error('请选择卡类型')
                return false
            }


            let cardTypeFilter = cardTypeData.filter(function (item) {
                return item.id == cardType;
            })

            let zeroLength = cardTypeFilter[0].cardLength

            if (zeroLength && zeroLength != '' && parseFloat(zeroLength) != 0) {
                this.setState({
                    cardNo: ArraySome.addPreZero(cardNo, zeroLength)
                })
                data = {
                    params: [{
                        "number": '', // 登记号/身份证号
                        "cardTypeID": cardType || '',     //卡类型id
                        "cardNo": ArraySome.addPreZero(cardNo, zeroLength) || '', //卡号
                    }]
                }
            }
        }



        $http.post('urlS', this, {
            code: "03040004",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {

                    this.setState({
                        userInfo: res.data || [],  // 用户数据
                        patNo: res.data.patNo || '',  // ID
                    }, () => {
                        if (!dataTableNo || dataTableNo != 'Y') {
                            this.dataTableTopData() // 就诊信息
                        }
                    });

                }
            }
        });
    }

    // 查询条件 --- 病区
    bqType = (e) => {
        this.setState({ bqType: e }, () => {
            this.BedChange(e)
            this.dataTableTopData() // 就诊信息
        });
    }

    // 查询条件 --- 结算
    jsType = (e) => {
        this.setState({ jsType: e });
    }
    // 查询条件 --- 结算类型
    chargeStatus = (e) => {
        this.setState({ chargeStatus: e });
    }
    // 查询条件 --- 时间类型
    time1 = (e) => {
        this.setState({ time1: e }, () => {
            this.dataTableTopData() // 就诊信息
        });
    }

    // 查询条件 --- 卡类型·
    cardType = (e) => {
        this.setState({ cardType: e }, () => {
            this.CardTypeChange(e)
        });
    }
    // 查询条件 --- 卡号
    cardNo = (e) => {
        let { readModeI } = this.state
        if (!readModeI) {
            return false
        }
        this.setState({ cardNo: e.target.value });
    }

    // Card
    CardTypeChange = (e) => {
        if (!e) {
            return false
        }
        let { cardTypeData } = this.state
        let readMode = cardTypeData.filter((item, i) => {
            return item.id == e;
        })

        switch (readMode[0] && readMode[0].readMode) {
            // 只可input
            case 'I':
                this.setState({
                    readModeI: true,
                    readModeR: false,
                    cardNo: "",

                })
                break;
            // 只可读卡
            case 'R':
                this.setState({
                    readModeR: true,
                    readModeI: false,
                    cardNo: "",
                })
                break;
            // 皆可
            default:
                this.setState({
                    readModeI: true,
                    readModeR: true,
                    cardNo: "",
                })
                break;
        }

    }

    // 查询条件 --- 登记号
    patNo = (e) => {
        this.setState({ patNo: e.target.value });
    }
    // 1.1.52.住院费用明细相关接口（就诊信息及费用信息接口）
    dataTableTopData = (e) => {
        let { pageSizeTop, pageTop, StartDateTop, EndDateTop, time1, bqType, jsType, cardType, cardNo, patNo, chargeStatus, bednumber } = this.state
        var data = {
            params: [{
                "number": patNo || '', // 登记号/身份证号
                "cardTypeID": cardType,   //卡类型id
                "cardNo": cardNo,    //卡号
                hospID: JSON.parse(window.sessionStorage.userData).hospID || '', //医院id
                // patID: this.state.userInfo.patID,  //病人id
                "stopDate": EndDateTop,
                "startDate": StartDateTop,
                "condition": time1,
                "wardID": bqType, //病区
                "payReasonID": jsType,  //费别
                "chargeStatus": chargeStatus,
                "bedID": bednumber

            }],
            pagination: [{
                pageSize: pageSizeTop,
                currentPage: pageTop,
            }]
        }

        $http.post('urlS', this, {
            code: "05300028",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    for (var i = 0; i < res.data.length; i++) {
                        res.data[i].key = i;
                    }
                    this.setState({
                        dataTableTop: res.data,
                        totalTop: res.total,
                        patBillID: '',
                    }, () => {
                        let { recordData, dataTable1 } = this.state
                        let newData = dataTable1.filter((item) => {
                            return item.number === recordData.number;
                        })
                        if (newData[0]) {
                            this.onClickRowPublicTop(newData[0])
                        } else {
                            this.clearnUserPayData()
                        }
                    });
                } else {
                    this.setState({
                        dataTable1: [],
                        total1: 0,
                        patBillID: '',

                    })
                    this.clearnUserPayData()
                }
            }
        });
    }
    // 操作行
    onClickRowPublicTop = (record) => {
        this.clearnUserPayData()
        let { recordData } = this.state
        this.setState({
            admID: record.admID,
            readCardType: 'read',
            dataTable1: [],
            patNo: record.patNo,
            admReasonCode: record.admReasonCode,
            //新出院结算合并
            comepnCode: '2101',
            YBPatDivdata: [],
            comepnCodeList: [],
            ybPayDivdata: '',
            InsuIPPayButton: '0',
            InsuIPPayModalvisible: false,
            trialflag: '',
            xnhBCTYPEList: [],
            xnhBCTYPE: '',
            ifsubmit: '0',
            patBillID: record ? record.patBillID : recordData.patBillID,
            recordData: record ? record : recordData,
            insuPayID: record ? record.insuPayID : recordData.insuPayID,
            source: record, fphm: record.fphm, fpdm: record.fpdm
        }, () => {
            this.searchUser('patNo', 'Y')
            //新出院结算合并
            this.userPayData()
            this.dataTable2()
            let payStatusCode = record ? record.payStatusCode : recordData.payStatusCode
            if (payStatusCode === 'TP') {
                //OB 需交费 TP预结算 P已结算
                this.setState({
                    disBtton1: false,
                    disBtton2: true,
                    disBtton3: false,
                    disBtton4: false,
                    disBtton5: true,
                    disBtton6: true,
                    disBtton7: false,
                })
            }
            if (payStatusCode === 'OB') {
                //OB 需交费 TP预结算 P已结算
                this.setState({
                    disBtton1: false,
                    disBtton2: false,
                    disBtton3: true,
                    disBtton4: false,		//结算
                    disBtton5: true,
                    disBtton6: false,
                    disBtton7: false,
                })
            }
            if (payStatusCode === 'P') {
                //OB 需交费 TP预结算 P已结算
                this.setState({
                    disBtton1: false,
                    disBtton2: true,
                    disBtton3: true,
                    disBtton4: true,
                    disBtton5: false,
                    disBtton6: true,
                    disBtton7: false,
                })
            }
        })
    }
    // 选中行操作
    setRowClassNamePublicTop = (record) => {
        return record.patBillID === this.state.patBillID ? 'clickRowStyle' : (record.chargeFlag === 'Y' ? "chargeFlag" : "");

    }
    // 选中行操作
    setRowClassNamePublic1 = (record) => {
        return record.patBillID === this.state.patBillID ? 'clickRowStyl' : '';
    }

    // userPayData
    userPayData = (record) => {

        var data2 = {
            params: [{
                "patBillID": this.state.patBillID || '', //就诊ID
            }],
        }
        $http.post('urlS', this, {
            code: "05300016",
            data: data2,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {

                    this.setState({
                        userPayData: res.data[0] || {}, //账户状态
                        subTypeFeeArr: res.subTypeFeeArr || [],
                    });

                } else {
                    this.setState({
                        userPayData: {},
                        subTypeFeeArr: [],
                    })
                }
            }
        });
    }
    // 显示分页总条数
    showTotal(total) {
        return `共 ${total} 条`;
    }
    onChangeTop = (page, pageSize) => {
        this.setState({ pageTop: page, pageSizeTop: pageSize, patNo: '' }, () => {
            // 重新调用查询方法
            this.dataTableTopData();
        })
    }

    // 条数改变的回调
    onShowSizeChangeTop = (current, size) => {
        this.setState({ pageTop: 1, pageSizeTop: size, patNo: '' }, () => {
            // 重新调用查询方法
            this.dataTableTopData();
        })

    }
    // 时间
    onChangeTimeTop = (date, dateString) => {
        this.setState({
            StartDateTop: dateString[0],    //开始日期
            EndDateTop: dateString[1],  //结束日期
        })

    }

    startChange(date) {
        this.setState({
            StartDateTop: date,
        })
    }

    endChange(date) {
        this.setState({
            EndDateTop: date,
        })
    }
    // 切换tabs的回调
    callback = (key) => {
        let { recordData } = this.state
        if (key == 1) {
            this.onChangeINSURegisterVisable()
            return
        }
        if (key == 2) {
            if (!this.state.admID || this.state.admID === '') {
                message.error('请先选择就诊信息')
                return false
            }
            if (this.patAccManagementChild) {
                this.patAccManagementChild.setState({
                    patNo: recordData.patNo,
                    admID: recordData.admID
                }, () => {
                    this.patAccManagementChild.searchUser()
                })
            }
        }
        this.setState({ activeKey: key });
    }

    //checkChange
    onSelectChange = (selectedRowKeys, selectedRows) => {
        let { accDepositIDinfo } = this.state
        selectedRows.map((item, i) => {
            accDepositIDinfo += item.accDID + '^'
        })

        this.setState({
            selectedRowKeys: selectedRowKeys,
            selectedRows: selectedRows,
            accDepositIDinfo: accDepositIDinfo
        })

    }

    // 试算
    budgetAndSettlement = () => {
        var data = {
            params: [{
                "billID": this.state.patBillID || '', //就诊ID,
                "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
            }],
        }

        $http.post('urlS', this, {
            code: "05300024",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    this.dataTableTopData();
                }
            }
        });
    };

    //医保费用上传
    InsuUPloadItem = async () => {
        if (this.state.recordData.payStatusCode != "OB") {
            message.error('此记录不是未结算状态，不能医保费用上传')
            return false
        }
        let openModal = Modal.info({
            title: "正在医保费用上传，请稍后......",
            content: <Spin size="large" />,
            onOk() { },
        });

        let insudata = {
            params: [{
                "billID": this.state.patBillID || '',
                "userID": JSON.parse(window.sessionStorage.userData).userID || '',
                "locID": JSON.parse(window.sessionStorage.userData).locID,
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4,
                "patID": this.state.userInfo.patID,  //病人id
                "admID": this.state.admID,
                "mac": JSON.parse(window.sessionStorage.ipConfig).mac,
            }],
        };
        let res = await INSUYBUtil.GoTOHISHttp(insudata, "05020007");    //调用his接口
        let errorCode = res.errorCode;
        openModal.destroy();
        if (+res.errorCode === 0) {
            this.setState({ insuAdmID: res.insuAdmID, readCardType: 'read' });
            Keup.ModalMessage(3, this, '医保费用上传成功!', '自动关闭', 'destroy', '确定', 'success')
        }else {
            Keup.ModalMessage(15, this, res.errorMessage, '自动关闭', 'destroy', '确定', 'error')
        }
        return errorCode
    };
    //取消医保费用上传
    CancleInsuUPloadItem = async () => {
        if (this.state.recordData.payStatusCode != "OB") {
            message.error('此记录不是未结算状态，不能取消医保费用上传')
            return false
        }
        let openModal = Modal.info({
            title: "正在取消医保费用上传，请稍后......",
            content: <Spin size="large" />,
            onOk() { },
        });
        let insudata = {
            params: [{
                "billID": this.state.patBillID || '',
                "userID": JSON.parse(window.sessionStorage.userData).userID || '',
                "locID": JSON.parse(window.sessionStorage.userData).locID,
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4,
                "patID": this.state.userInfo.patID,  //病人id
                "admID": this.state.admID,
                "mac": JSON.parse(window.sessionStorage.ipConfig).mac,
            }],
        }

        let res = await INSUYBUtil.GoTOHISHttp(insudata, "05020008");    //调用his接口
        let errorCode = res.errorCode
        openModal.destroy();
        if (res.errorCode == '0') {
            this.setState({ insuAdmID: res.insuAdmID });
            Keup.ModalMessage(3, this, '医保费用取消成功!', '自动关闭', 'destroy', '确定', 'success')
        }
        else {
            ///message.warn(res.errorMessage);
            this.Cancellationoftrialcalculation()
            Keup.ModalMessage(15, this, res.errorMessage, '自动关闭', 'destroy', '确定', 'error')
        }
        return errorCode
    }
    comepnCodeonChange = (val, opt) => {
        this.setState({
            comepnCode: val,
            ifNeedTreatWay: opt.props.title.includes('按病种') ? 'Y' : 'N',
        });
    }

    insuMdHosTypeonChange = (val) => {
        this.setState({
            insuMdHosType: val
        });
    };


    ifsubmitonChange = (e) => {
        this.setState({ ifsubmit: e });
    }
    xnhBCTYPEListChange = (e) => {
        this.setState({ xnhBCTYPE: e });
    }
    xnhredeemNo = async () => {
        try {
            if (this.state.xnhjgCode !== '') {
                var paramsdata = {
                    params: [{
                        "insuAdmID": this.state.insuAdmID,
                        "userID": JSON.parse(window.sessionStorage.userData).userID || '',
                        "locID": JSON.parse(window.sessionStorage.userData).locID,
                        "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                        "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                        "xnhjgCode": (this.state.xnhjgCode),			//
                    }]
                }
                let YBPatDataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210063");    //调用his接口
                if (YBPatDataobj.errorCode == '0') {
                    let xnhBCTYPEList = YBPatDataobj.xnhBCTYPEList;
                    this.setState({
                        xnhBCTYPEList: xnhBCTYPEList,
                    });
                }
                else {
                    message.warn(res.errorMessage);
                }
            }
        } catch (error) {
            message.warning("异常:" + error)
        }
    }

    //医保预结算界面
    InsuIPPayModal = async (flag) => {
        if (this.state.recordData.payStatusCode != "OB") {
            message.error('此记录不是未结算状态，不能医保费用预结算')
            return false
        }
        let openModal = Modal.info({
            title: "正在医保费用预结算，请稍后......",
            content: <Spin size="large" />,
            onOk() { },
        });
        this.setState({
            YBPatDivdata: [], comepnCodeList: [], ybPayDivdata: '', InsuIPPayButton: '0', InsuIPPayModalvisible: false, insuPayID: '', xnhtreatCodeist: [],
            treatCode: '', icdAllNoEList: [], icdAllNo: '', INSUICDCode: '', INSUICDDesc: '',traumaFlag:'N', thirdFlag:'N', insuMdHosType:''
        });
        this.setState({ InsuIPPayButton: flag });
        let errorCode = '0'
        this.xnhredeemNo()
        //查询有没记录医保病人信息
        var paramsdata = {
            params: [{
                "admID": this.state.admID, //就诊记录
                "userID": JSON.parse(window.sessionStorage.userData).userID || '', //操作人
                "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4, //ip
                "hospID": JSON.parse(window.sessionStorage.userData).hospID || '', //医院
            }]
        }
        let resObj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05020017");    //调用his接口

        if (resObj.errorCode != '0') {
            message.warn(resObj.errorMessage);
            return
        }
        let insuInfoObj = resObj.result
        let divdata = insuInfoObj.patYBData ? insuInfoObj.patYBData : [];
        let insuTypeList = insuInfoObj.insuTypeData
        let insuMedTypeList = insuInfoObj.insuMedTypeData
        let diseCodeList = insuInfoObj.diseCodeData
        let birctrlTypeList = insuInfoObj.birctrlTypeData
        this.setState({
            insuAdmID: insuInfoObj.insuAdmID,
            admReasomID: insuInfoObj.admReasomID,
            reasonCode: insuInfoObj.reasonCode,
            insuType: insuInfoObj.insuType,
            insuMedType: insuInfoObj.insuMedType,
            INSUICDCode: insuInfoObj.mainDiagCode,
            INSUICDDesc: insuInfoObj.mainDiagDesc,
            YBPatDivdata: divdata,
            InsuIPPayModalvisible: true

        });
        openModal.destroy();
        return
        if (YBPatDataobj.errorCode == '0') {
            this.setState({
                insuAdmID: YBPatDataobj.insuAdmID,
                xnhjgCode: YBPatDataobj.xnhjgCode,
                treatCode: YBPatDataobj.treatCode,
                icdAllNo: YBPatDataobj.icdAllNo,
                INSUICDCode: YBPatDataobj.icdAllNo,
                INSUICDDesc: YBPatDataobj.icdAllDesc,
                readCardType: 'read'
            }, () => {
                this.xnhtreatment()		//加载治疗方式
            });
            let { hospID } = JSON.parse(window.sessionStorage.userData).hospID;
            let paramsdata = {
                params: [{
                    hospID: hospID,
                    admReasonID: YBPatDataobj.admReasomID,
                    ybPatdata: YBPatDataobj.result,
                    admType: 'I'
                }]
            }
            let YBPatDivdata = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210040");    //调用his接口    //组织医保病人信息
            errorCode = YBPatDataobj.errorCode
            if (YBPatDivdata.errorCode == '0') {
                openModal.destroy();
                let Divdata = YBPatDivdata.result;
                let ComepnCodeList = YBPatDivdata.comepnCodeList;
                this.setState({ YBPatDivdata: Divdata, comepnCodeList: ComepnCodeList, personalData: YBPatDataobj.result, InsuIPPayModalvisible: true });
                openModal.destroy();
            }
        }
        else {
            message.warn(res.errorMessage);
            openModal.destroy();
        }
        return errorCode
    }
    //医保预结算
    InsuIPPayPRE = async (ybPayType) => {
        let openModal = Modal.info({
            title: ybPayType === 'PAY' ? "正在医保结算，请稍后......" : '正在医保预结算，请稍后......',
            content: <Spin size="large" />,
            onOk() { },
        });
        let insudata = {
            params: [{
                "ybPayType": ybPayType,  //医保预结算
                "insuPayID": this.state.insuPayID,  //医保预结算记录ID
                "admID": this.state.admID || '', // 结算类型
                "userID": JSON.parse(window.sessionStorage.userData).userID || '',
                "paytype": "I",
                "locID": JSON.parse(window.sessionStorage.userData).locID,
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4,
                "mac": JSON.parse(window.sessionStorage.ipConfig).mac,
                "billID": this.state.patBillID, //交款记录id
                "recordID": this.state.recordID || '',
                "patID": this.state.userInfo.patID,  //病人id
                "certType": this.state.certType,  //病人id
                "certNo": this.state.certNo,  //病人id
                "insuAdmID": this.state.insuAdmID,
                "middleSettleFlag": this.state.middleSettleFlag,
                "userAccFlag": this.state.userAccFlag,
                "traumaFlag":this.state.traumaFlag,         //外伤标识
                "thirdFlag":this.state.thirdFlag,           //第三方标识
                "insuMdHosType":this.state.insuMdHosType    //住院类型
            }]
        }
        let YBPayobj = await INSUYBUtil.GoTOHISHttp(insudata, "05020009");    //调用his接口
        openModal.destroy() //关闭等待界面
        return YBPayobj
    }
    //医保预结算
    InsuIPPay = async (ybPayType) => {
        let openModal = Modal.info({
            title: ybPayType === 'PAY' ? "正在医保结算，请稍后......" : '正在医保预结算，请稍后......',
            content: <Spin size="large" />,
            onOk() { },
        });
        let insudata = {
            params: [{
                "ybPayType": ybPayType,  //医保预结算
                "insuPayID": this.state.insuPayID,  //医保预结算记录ID
                "admID": this.state.admID || '', // 结算类型
                "userID": JSON.parse(window.sessionStorage.userData).userID || '',
                "paytype": "I",
                "locID": JSON.parse(window.sessionStorage.userData).locID,
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4,
                "mac": JSON.parse(window.sessionStorage.ipConfig).mac,
                "billID": this.state.patBillID, //交款记录id
                "recordID": this.state.recordID || '',
                "patID": this.state.userInfo.patID,  //病人id
                "certType": this.state.certType,  //病人id
                "certNo": this.state.certNo,  //病人id
                "insuAdmID": this.state.insuAdmID,
                "middleSettleFlag": this.state.middleSettleFlag,
                "userAccFlag": this.state.userAccFlag,
                "traumaFlag":this.state.traumaFlag,         //外伤标识
                "thirdFlag":this.state.thirdFlag,           //第三方标识
                "insuMdHosType":this.state.insuMdHosType    //住院类型
            }]
        }
        let YBPayobj = await INSUYBUtil.GoTOHISHttp(insudata, "05020010");    //调用his接口，医保正式结算
        openModal.destroy() //关闭等待界面
        return YBPayobj
    }
    //医保预结算
    InsuIPPrePay = async () => {
        //InsuIPPayButton Pay 医保结算
        /**
         * @ByYQL: 读医保卡或医保电子凭证
         * Create 2021-12-26
         */
        /**
         * @ByYQL: 统一基线版前端调用DLL封装
         * iShowForm ： 是否弹窗 0 不弹  1 弹
         * iCardType ： 01：电子凭证   02：身份证   03：社保卡
         * operatorId ：收款员工号
         * operatorName : 	收款员姓名
         * officeId ：科室id
         * officeName ： 科室名称
         * patID : 病人id
         * Create 2022-1-24
         */
        var certType = this.state.certType;
        var certNo = this.state.certNo;
        let dllInputdata = {
            "iShowForm": 0,
            "iCardType": certType,
            "operatorId": JSON.parse(window.sessionStorage.userData).userCode,
            "operatorName": JSON.parse(window.sessionStorage.userData).userName,
            "officeId": JSON.parse(window.sessionStorage.userData).locID,
            "officeName": JSON.parse(window.sessionStorage.userData).locDesc,
            "patID": this.state.userInfo.patID
        };
        var retStr = await INSUYBUtil.ReadInsuCard(dllInputdata);
        console.log('retStr', retStr);
        let resObj = JSON.parse(retStr);
        if (resObj.errorCode != "0") {
            message.warn(resObj.errorMessage);
            return
        }
        certNo = resObj.result.cardInfo;
        this.setState({
            certType,
            certNo,
            // cardSN
        });

        // 选治疗方式必须选诊断
        if (this.state.certNo == '') {
            message.warning('请输入就诊凭证编号!')
            return
        }
        this.setState({ InsuIPPayModalvisible: false, comepnCodeList: [], insuPayID: '', ifNeedTreatWay: 'N' });
        let res = await this.InsuIPPayPRE();
        //let res = JSON.parse(YBPayobj);
        if (res.errorCode == '0') {
            //let secondsToGo=10
            this.setState({ insuPayID: res.result.insuPayID, ybPayDivdata: res.result.ybPayDivdata });
            if (this.state.InsuIPPayButton === '4') {
                //结算按钮
                ///打开结算界面
                this.OpenSettlement()
            }
            if (this.state.InsuIPPayButton === '2') {
                this.setState({ InsuIPPayModalvisible: false });
                // this.InsuIPPayModal(2)	//刷新界面  2022-7-21 ByYQL  当前预结算已完成，可取消再次弹框展示信息
                infoModal({
                    title: '试算结果：',
                    content: (
                        <div>
                            {res.result?.prePayInfo ? res.result?.prePayInfo : '当前未能获取到试算结果'}
                        </div>
                    ),
                })
            }
        } else {
            //医保结算失败
            this.setState({ YBPatDivdata: [], comepnCodeList: [], ybPayDivdata: '', InsuIPPayButton: '0', InsuIPPayModalvisible: false, xnhBCTYPEList: []});
            //Smessage.warn(res.errorMessage);
            Modal.error({
                title: '错误信息',
                content: res.errorMessage,
            });
            // Keup.ModalMessage(30, this, res.errorMessage, '自动关闭', 'destroy', '确定', 'error')
        }


    }
    //异地医保签到
    InsuSignin = async () => {
        let insupaydata = {
            params: [{
                "billID": this.state.patBillID || '',
                "userID": JSON.parse(window.sessionStorage.userData).userID || '',
                "locID": JSON.parse(window.sessionStorage.userData).locID,
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4,
                "patID": this.state.userInfo.patID,  //病人id
                "reasonCode": this.state.recordData.admReasonCode

            }],
            "code": "05210072"
        }
        let YBPatDivdata = await INSUYBUtil.insuYBAHSYB("InsuSignin", insupaydata, "ReadYDYBYBCard/INSUYBPAY.dll");
        let res = JSON.parse(YBPatDivdata);
        let errorCode = res.errorCode
        if (res.errorCode == '0') {
            Keup.ModalMessage(3, this, '异地医保签到成功!', '自动关闭', 'destroy', '确定', 'success')
        }
        else {
            Keup.ModalMessage(15, this, res.errorMessage, '自动关闭', 'destroy', '确定', 'error')
        }
        return errorCode
    }
    //异地医保签退
    InsuSignout = async () => {
        let insupaydata = {
            params: [{
                "billID": this.state.patBillID || '',
                "userID": JSON.parse(window.sessionStorage.userData).userID || '',
                "locID": JSON.parse(window.sessionStorage.userData).locID,
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4,
                "patID": this.state.userInfo.patID,  //病人id
                "reasonCode": this.state.recordData.admReasonCode

            }],
            "code": "05210072"
        }
        let YBPatDivdata = await INSUYBUtil.insuYBAHSYB("InsuSignout", insupaydata, "ReadYDYBYBCard/INSUYBPAY.dll");
        let res = JSON.parse(YBPatDivdata);
        let errorCode = res.errorCode
        if (res.errorCode == '0') {
            Keup.ModalMessage(3, this, '异地医保签退成功!', '自动关闭', 'destroy', '确定', 'success')
        }
        else {
            Keup.ModalMessage(15, this, res.errorMessage, '自动关闭', 'destroy', '确定', 'error')
        }
        return errorCode
    }
    //金额1回车
    onPressEnter1 = () => {
        let { payType, otherPay, otherPayDis } = this.state
        setTimeout(() => {
            this.myRef3.current.focus();
        }, 300)



    }
    InsuRighting = async () => {
        ///住院患者医保结算冲正
        let openModal = Modal.info({
            title: "正在进行医保结算冲正,请稍后......",
            content: <Spin size="large" />,
            onOk() { },
        });
        let insudata = {
            "params": [{
                "admID": this.state.admID,
                "userID": JSON.parse(window.sessionStorage.userData).userID,
                "billID": this.state.patBillID,
                "insuPayID": "",
                "hospID": JSON.parse(window.sessionStorage.userData).hospID,
                "patID": this.state.userInfo.patID || '',  //病人id
                "readCardType": 'numble',            //this.state.readCardType
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id,
                "locID": JSON.parse(window.sessionStorage.userData).locID,//登录科室,
                "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4,
                "mac": JSON.parse(window.sessionStorage.ipConfig).mac

            }],
        }
        let res = await INSUYBUtil.GoTOHISHttp(insudata, "05020018");    //调用his接口
        if (res.errorCode == '0') {
            Keup.ModalMessage(3, this, '住院结算冲正成功!', '自动关闭', 'destroy', '确定', 'success')
        }
        else {
            Keup.ModalMessage(15, this, res.errorMessage, '自动关闭', 'destroy', '确定', 'error')
        }
        openModal.destroy() //关闭等待界面
        return res.errorCode
    }
    InsuIPRegRighting = async () => {
        ///住院患者医保结算冲正
        let openModal = Modal.info({
            title: "正在进行医保登记冲正,请稍后......",
            content: <Spin size="large" />,
            onOk() { },
        });
        let insudata = {
            "params": [{
                "admID": this.state.admID,
                "userID": JSON.parse(window.sessionStorage.userData).userID,
                "insuPayID": "",
                "hospID": JSON.parse(window.sessionStorage.userData).hospID,
                "patID": this.state.userInfo.patID || '',  //病人id
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id,
                "locID": JSON.parse(window.sessionStorage.userData).locID,//登录科室,
                "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4,
                "mac": JSON.parse(window.sessionStorage.ipConfig).mac
            }],
        }
        let res = await INSUYBUtil.GoTOHISHttp(insudata, "05020019");    //调用his接口
        if (res.errorCode == '0') {
            Keup.ModalMessage(3, this, '医保登记冲正成功!', '自动关闭', 'destroy', '确定', 'success')
        }
        else {
            Keup.ModalMessage(15, this, res.errorMessage, '自动关闭', 'destroy', '确定', 'error')
        }
        openModal.destroy() //关闭等待界面
        return res.errorCode
    }


    //金额1回车
    onPressEnter2 = () => {
        let { payType, otherPay, otherPayDis } = this.state
        // if setTimeout(() => {
        //     this.myRef5.current.focus();
        // }, 300)
    }

    /**
    * @ByShizi: 结算弹框 - 结算防抖，避免多次触发
    * Create 2022-07-27
    * */
    Settlement = Util.debounce(async () => {
        let payopenModal = Modal.info({
            title: "正在his结算，请稍后......",
            content: <Spin size="large" />,
            onOk() { },
        });
        //先账单
        this.setState({
            recordID: '',
            ipInsuType: ''
        })
        let hisDataobj = await this.bill('1')
        let { recordData } = this.state

        if (hisDataobj.errorCode === '0') {
            this.setState({
                ipInsuType: recordData.ipInsuType
            })
            let ipInsuType = recordData.ipInsuType
            if (ipInsuType === 'Y') {
                ///读卡？
                //判断是否是医保，进行医保费用上传
                let errorCode = await this.InsuUPloadItem();	//进行医保费用上传
                if (+errorCode === 0){
                    //进行医保预结算
                    let errorCode = await this.InsuIPPayModal('4')
                } else {
                    this.handleCancel()
                }
            }
            else {
                this.OpenSettlement()
            }
        } else {
            Keup.ModalMessage(15, this, hisDataobj.errorMessage, '自动关闭', 'destroy', '确定', 'error')
        }
        setTimeout(() => {
            payopenModal.destroy() //关闭等待界面
        }, 1000);

    })

    // 结算弹框
    OpenSettlement = async () => {
        var paramsdata = {
            params: [{
                "admID": this.state.admID || '', //就诊ID,
                "billID": this.state.patBillID || '', //账单ID,
                "insuPayID": this.state.insuPayID,
                "paytype": "I",
                "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
                "accDepositIDinfo": this.state.accDepositIDinfo,
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id,
                "locID": JSON.parse(window.sessionStorage.userData).locID,//登录科室,
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4, 				//IP
            }],
        }
        let hisprepayobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05300017");    //his预算
        let errorCode = hisprepayobj.errorCode
        if (errorCode === '0') {
            this.setState({
                recordID: hisprepayobj.recordID
            })
        }
        else {
            Keup.ModalMessage(15, this, hisprepayobj.errorMessage, '自动关闭', 'destroy', '确定', 'error')
            return
        }
        var paramsdata = {
            params: [{
                recordID: this.state.recordID || '',
            }],
        }
        let hisdataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05300021");    //his结算数据
        errorCode = hisdataobj.errorCode
        let accpayBalance = 0
        let payAccIPAmt = 0
        if (errorCode === '0') {
            payAccIPAmt = parseFloat(hisdataobj.data[0].accAmtBalance)
            this.setState({
                payAccIPAmt: parseFloat(payAccIPAmt).toFixed(2),
                accpayBalance: 0.00
            })
            // accpayBalance = parseFloat(Keup.MoneyReplace(hisdataobj.data[0].accAmtBalance)) - parseFloat(hisdataobj.data[0].leftAmt)
            // if (parseFloat(accpayBalance) < 0) {
            //     payAccIPAmt = parseFloat(hisdataobj.data[0].accAmtBalance)
            //     this.setState({
            //         payAccIPAmt: parseFloat(payAccIPAmt).toFixed(2),
            //         accpayBalance: 0.00
            //     })

            // }
            // else {
            //     payAccIPAmt = parseFloat(hisdataobj.data[0].leftAmt)
            //     this.setState({
            //         payAccIPAmt: parseFloat(payAccIPAmt).toFixed(2),
            //         accpayBalance: parseFloat(accpayBalance).toFixed(2),
            //     })
            // }
            this.setState({
                leftAmt: hisdataobj.data[0].leftAmt,
                leftAmtSur: hisdataobj.data[0].leftAmt,
                accAmtBalance: hisdataobj.data[0].accAmtBalance,
                patAmt: hisdataobj.data[0].patAmt,
                paywamtData: hisdataobj.data[0].paywamtData
            })
            let payWListData = [
                {
                    key: 1,
                    payWID: this.state.otherPayData[0].paywID,
                    payWCode: this.state.otherPayData[0].paywCode,
                    payWDesc: this.state.otherPayData[0].paywDesc,
                    payWamt: parseFloat(parseFloat(hisdataobj.data[0].leftAmt) - parseFloat(payAccIPAmt)).toFixed(2),
                }
            ]
            this.setState({
                payWListData: payWListData,
            })
            this.checkCash()
            this.checkpayMoneySurplus()
            this.setState({
                visible: true,
                editingKey: ''
            })

        }
    }
    handleCancel = () => {
        this.setState({
            visible: false,
            visibleMoney: false,
            visibleMoney2: false,
        })
        this.dataTableTopData();
    }

    handleCancelMoney = () => {
        this.setState({
            leftAmt: '',
            patAmt: '',
            payWListData: [],
            paywamtData: '',
            leftAmtSur: '',
            accAmtBalance: '',
            accpayBalance: '',
            zeroPay: '0.00', // 找零
            otherPayMoney: '0.00', // 其他支付金额
            cashInCashVal: '0.00', // 实收现金
            disXJ: false,
            payAccIPAmt: '0.00',	//住院结算参与账户的金额
        })
        this.handleCancel()
        this.unbudgetAndSettlement()
    }
    handleCancelInsuIPPayModal = () => {
        this.setState({ comepnCode: '2101', YBPatDivdata: [], comepnCodeList: [], ybPayDivdata: '', InsuIPPayButton: '0', InsuIPPayModalvisible: false, xnhBCTYPEList: [], xnhBCTYPE: '', ifsubmit: '', });
    }
    //账单
    bill = async (flag) => {
        var paramsdata = {
            params: [{
                "admID": this.state.admID || '', //就诊ID,
                "billID": this.state.patBillID || '', //账单ID,
                "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
                'ordExecStr': ''
            }]
        }
        let hisDataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05300012");    //his试算
        let errorCode = hisDataobj.errorCode
        if (errorCode === '0' && flag !== '1') {
            Keup.ModalMessage(3, this, hisDataobj.errorMessage, '关闭', 'destroy', "现在就去", 'success')
        }
        return hisDataobj
    }


    /**
     * @ByYQL: 医保结算前进行卡验密
     * 如需取消卡验密流程，则将调用handleVerfiyOk的地方直接替换成handleOK
     * Create 2021-12-26
     */
    handleVerfiyOk = Util.debounce(async () => {
        var certType = this.state.certType;
        if (certType == "03") {
            message.loading('验密进行中,请提醒患者输入密码...')
            var retStr = await INSUYBUtil.VerfiyPin("{}");
            let resObj = JSON.parse(retStr);
            if (resObj.errorCode != "0") {
                message.warn(resObj.errorMessage);
                return
            }
            this.handleOK()
        } else { this.handleOK() }
    });

    handleOK = async () => {
        let { payType, cashInCashVal, zeroPay, otherPayMoney, leftAmt, payAccIPAmt } = this.state
        if ((cashInCashVal !== '') & (parseFloat(cashInCashVal) !== 0)) {
            if (parseFloat(zeroPay) < 0) {
                message.error('应找金额小于0，请核实实收金额是否正确')
                return false
            }
        }
        let paywAmt = 0 			//支付方式金额
        let notpayleftAmt = 0 	//剩余没结算金额
        let payWIDinfo = ""
        let errormessage = ''
        for (var i = 0; i < this.state.payWListData.length; i++) {
            if ((parseFloat(this.state.payWListData[i].payWamt) !== 0) & (this.state.payWListData[i].payWamt !== '')) {
                if (this.state.payWListData[i].payWID === '') {
                    errormessage = "支付方式列表存在支付方式为空，请选择支付方式"
                }
                paywAmt = paywAmt + parseFloat(this.state.payWListData[i].payWamt)
                if (payWIDinfo === '') {
                    payWIDinfo = this.state.payWListData[i].payWID + '^' + parseFloat(this.state.payWListData[i].payWamt)
                }
                else {
                    payWIDinfo = payWIDinfo + String.fromCharCode('2') + this.state.payWListData[i].payWID + '^' + parseFloat(this.state.payWListData[i].payWamt)
                }
            }
        }
        if (errormessage !== '') {
            message.error(errormessage)
            return false
        }
        notpayleftAmt = (parseFloat(leftAmt) - parseFloat(payAccIPAmt)).toFixed(2) - parseFloat(paywAmt)
        if (parseFloat(notpayleftAmt) !== 0) {
            message.error('结算金额不符，还存在金额：' + parseFloat(notpayleftAmt) + "没计算进支付方式")
            return false
        }
        let openModalpay = Modal.info({
            title: "正在结算，请稍后......",
            content: <Spin size="large" />,
            onOk() { },
        });
        var paramsdata = {
            params: [{
                "recordID": this.state.recordID || '',
                "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
                "payWIDinfo": payWIDinfo,
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id,
                "locID": JSON.parse(window.sessionStorage.userData).locID,//登录科室,
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4, 				//IP
                'patBillID': this.state.patBillID || '', //账单ID,
                'payAccIPAmt': parseFloat(payAccIPAmt), //参与结算的账户金额,
            }]
        }
        let Updatapaywobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05300018");    //his更新支付方式
        let errorCode = Updatapaywobj.errorCode;
        if (errorCode === '0') {
            if (this.state.ipInsuType === 'Y') {
                //医保确认结算
                let res = await this.InsuIPPay();
                if (res.errorCode == '0') {

                }
                else {
                    message.error(res.errorMessage)
                    Keup.ModalMessage(5, this, res.errorMessage, '自动关闭', 'destroy', '确定', 'error')
                    this.unbudgetAndSettlement()	//删除预结算记录
                    this.handleCancel()
                    return
                }
            }
            var paramsdata = {
                params: [{
                    "recordID": this.state.recordID || '',
                    "admID": this.state.admID || '', //就诊ID,
                    "billID": this.state.patBillID || '', //就诊ID,
                    "paytype": "I",
                    "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
                    "accDepositIDinfo": this.state.accDepositIDinfo,
                    "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id,
                    "locID": JSON.parse(window.sessionStorage.userData).locID,//登录科室,
                    "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                    "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4, 				//IP
                }]
            }
            let Compaywobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05300019");    //his收费确认
            let errorCode = Compaywobj.errorCode;
            if (errorCode === '0') {
                message.success(Compaywobj.errorMessage)
                this.handleCancel()
                this.setState({
                    compleRecordIDinfo: Compaywobj.compleRecordIDinfo
                }, () => {
                    console.log(JSON.parse(window.sessionStorage.userData).hospCode)
                    //长春医院打印凭证
                    if (JSON.parse(window.sessionStorage.userData).hospCode === 'H19') {
                        // 打印
                        this.print()

                    } else {
                        /**
                         * @ByYQL: 新住院结算打印功能
                         *  反参增加 INVPrintMethod
                         *  值域：空 或 JINSHUI     表示金税发票打印
                         *  LODOP         lodop打印
                         *  RAQSOFT      润乾打印
                         * Create 2022-2-10
                         */
                        if (Compaywobj.INVPrintMethod == '' || Compaywobj.INVPrintMethod == 'JINSHUI') {
                            this.loadInvoiceMessage()
                        }else if(Compaywobj.invoiceFileUrl)
                        {
                            this.iframeRef && this.iframeRef.modifyVisible(true,Compaywobj.invoiceFileUrl)
                        }else {
                            this.print()
                        }
                    }

                })
            } else {
                message.error(Compaywobj.errorMessage)
                this.unbudgetAndSettlement()	//删除预结算记录
            }
        }
        else {
            message.error(Updatapaywobj.errorMessage)
        }
        openModalpay.destroy() //关闭等待界面
    };
    print = () => {
        var data = {
            params: [{
                "recordID": this.state.recordID || '',
                "billID": this.state.patBillID || '',
                "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
            }]
        };
        $http.post('urlADS', this, {
            code: "05100382",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    $loadTemplate('SettlementVoucher', res.result);
                }
            }
        });
    };
    // 收取住院账户余额
    onChangepayAccIPAmt = (e) => {
        let val = e.target.value
        let newVal = Keup.inputMoneyReplace(val)
        if (newVal === '') { newVal = 0 }
        //判断账户余额
        if (parseFloat(newVal) > parseFloat(this.state.accAmtBalance)) {
            message.error('住院账户余额只有：' + this.state.accAmtBalance + ' 不能超出')
            this.setState({
                payAccIPAmt: this.state.payAccIPAmt
            })
            return
        }
        let accpayBalance = parseFloat(Keup.inputMoneyReplace(this.state.accAmtBalance)) - parseFloat(newVal)
        if (parseFloat(accpayBalance) < 0) {
            this.setState({
                accpayBalance: 0.00
            })
        }
        else {
            this.setState({
                accpayBalance: parseFloat(accpayBalance).toFixed(2),
            })
        }
        this.setState({
            payAccIPAmt: newVal
        })
        //先对支付方式列表初始化
        let payWListData = [
            {
                key: 1,
                payWID: this.state.otherPayData[0].paywID,
                payWCode: this.state.otherPayData[0].paywCode,
                payWDesc: this.state.otherPayData[0].paywDesc,
                payWamt: parseFloat(parseFloat(this.state.leftAmt) - parseFloat(newVal)).toFixed(2),
            }
        ]
        this.setState({
            payWListData: payWListData,
        })
        this.checkCash()
        this.checkpayMoneySurplus()
    }
    //检查现金支付
    checkCash = () => {
        let payCashCodeamt = 0 	//现金金额
        for (var i = 0; i < this.state.payWListData.length; i++) {
            if (this.state.payWListData[i].payWCode === 'CASH') {
                if (parseFloat(this.state.payWListData[i].payWamt) !== 0) {
                    payCashCodeamt = payCashCodeamt + parseFloat(this.state.payWListData[i].payWamt)
                }
            }
        }
        if (parseFloat(payCashCodeamt) < 0) {
            this.setState({ zeroPay: parseFloat(payCashCodeamt).toFixed(2), cashInCashVal: 0.00 })
        } else {
            this.setState({ disXJ: true, cashInCashVal: parseFloat(payCashCodeamt).toFixed(2), zeroPay: 0.00 })
        }
    }
    //判断返回支付方式代码
    checkPayCode = (value) => {
        for (var i = 0; i < this.state.otherPayData.length; i++) {
            if (this.state.otherPayData[i].paywID === value) {
                return this.state.otherPayData[i].paywCode + '^' + this.state.otherPayData[i].paywDesc
            }
        }
        return ''
    }
    // 实收现金
    cashInCash = (val) => {
        let cashInCashVal = Keup.MoneyReplace(val)
        if (cashInCashVal === '') { cashInCashVal = 0 }
        let payCashCodeamt = 0 	//现金金额
        for (var i = 0; i < this.state.payWListData.length; i++) {
            if (this.state.payWListData[i].payWCode === 'CASH') {
                if (parseFloat(this.state.payWListData[i].payWamt) !== 0) {
                    payCashCodeamt = payCashCodeamt + parseFloat(this.state.payWListData[i].payWamt)
                }
            }
        }
        this.setState({
            cashInCashVal: cashInCashVal // 金额过滤
        })
        let zeroPay = parseFloat(parseFloat(cashInCashVal) - parseFloat(payCashCodeamt)).toFixed(2)// 找零
        this.setState({
            zeroPay: zeroPay // 找零
        })

    }
    // 支付方式选择
    payWSelect = (e) => {
        //editingKey
        const newData = [...this.state.payWListData];
        const index = newData.findIndex(item => this.state.editingKey === item.key);
        if (index > -1) {
            const item = newData[index];
            newData[index].payWID = e
            for (var i = 0; i < this.state.otherPayData.length; i++) {
                if (this.state.otherPayData[i].paywID === e) {
                    newData[index].payWCode = this.state.otherPayData[i].paywCode
                    newData[index].payWDesc = this.state.otherPayData[i].paywDesc
                }
            }
        }
        this.setState({ payWListData: newData });
        this.checkCash()
        this.checkpayMoneySurplus()
    }
    ///列表支付方式金额输入
    payMoney = (e) => {
        let val = e.target.value
        let newVal = Keup.inputMoneyReplace(val)
        if (newVal === '') { newVal = 0 }
        const newData = [...this.state.payWListData];
        const index = newData.findIndex(item => this.state.editingKey === item.key);
        if (index > -1) {
            newData[index].payWamt = newVal
        }
        this.setState({ payWListData: newData });
        this.checkCash()
        this.checkpayMoneySurplus()
    }
    ///检查支付方式剩余金额
    checkpayMoneySurplus = () => {
        let { leftAmt, payAccIPAmt } = this.state
        let paywAmt = 0 			//支付方式金额
        let surplusamt = 0 	//剩余没结算金额
        for (var i = 0; i < this.state.payWListData.length; i++) {
            if ((parseFloat(this.state.payWListData[i].payWamt) !== 0) & (this.state.payWListData[i].payWamt !== '')) {
                paywAmt = paywAmt + parseFloat(this.state.payWListData[i].payWamt)
            }
        }
        surplusamt = (parseFloat(leftAmt) - parseFloat(payAccIPAmt)).toFixed(2) - parseFloat(paywAmt)
        this.setState({ surplusamt: parseFloat(surplusamt) });
    }
    ///列表支付方式金额输入焦点事件
    payMoneyonFocus = (e) => {
        let val = e.target.value
        let newVal = Keup.inputMoneyReplace(val)
        if (newVal === '0.00') { newVal = '' }
        if (newVal === '0') { newVal = '' }
        const newData = [...this.state.payWListData];
        const index = newData.findIndex(item => this.state.editingKey === item.key);
        if (index > -1) {
            newData[index].payWamt = newVal
        }
        this.setState({ payWListData: newData });

    }
    dataTable2 = () => {
        var data = {
            params: [{
                "patBillID": this.state.patBillID || '', //就诊ID,
            }],
        }

        $http.post('urlS', this, {
            code: "05300020",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {

                    this.setState({
                        dataTable2: res.data || []
                    })
                }
            }
        });
    }


    // 费用清单
    ListOfHospitalizationExpenses = () => {


        this.setState({
            visibleMoney: true
        })
    }
    // 设置支付方式列表行属性
    ChangepayWonRow = (record) => {
        return {
            // 双击行编辑
            onDoubleClick: () => {
                this.props.form.resetFields();
                this.setState({ editingKey: record.key });
            },
        }
    }
    // 拆分账单

    SplitTheBill = () => {
        this.setState({
            visibleMoney2: true,
            paras: {
                patBillID: this.state.patBillID,
                userInfo: this.state.userInfo,
            }
        })
    }

    // 取消试算
    Cancellationoftrialcalculation = () => {
        var data = {
            params: [{
                "billID": this.state.patBillID || '', //就诊ID,
                "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
            }],
        }

        $http.post('urlS', this, {
            code: "05300025",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    this.dataTableTopData();
                }
            }
        });
    }
    // 取消预结算
    unbudgetAndSettlement = async () => {

        let { patBillID } = this.state;
        ///判断付款记录是否预结算状态
        let paramsdata = {
            params: [{
                "billID": patBillID, //付款记录串
                "invtype": "PAY",   //his交易流水
                "userID": JSON.parse(window.sessionStorage.userData).userID || '', //操作人
                "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4, //ip
                "hospID": JSON.parse(window.sessionStorage.userData).hospID || '', //医院
            }]
        }
        let hisdataobj1 = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210081");    //调用his接口
        if (hisdataobj1.errorCode != '0') {
            message.warn(hisdataobj1.errorMessage);
            return
        }
        let hisdataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210047");    //调用his接口
        if (hisdataobj.errorCode != '0') {
            message.warn(hisdataobj.errorMessage);
            return
        }
        var insuPayID = hisdataobj.insuPayIDinfo
        if (insuPayID != "") {
            ///医保退费
            let dllInputdata = {
                "params": [{
                    "billID": this.state.patBillID, //账单ID
                    "userID": JSON.parse(window.sessionStorage.userData).userID,
                    "insuPayID": insuPayID,
                    "insuPayData": hisdataobj,
                    "hospID": JSON.parse(window.sessionStorage.userData).hospID,
                    "patID": this.state.userInfo.patID || '',  //病人id
                    "readCardType": 'numble'             //this.state.readCardType
                }],
                "code": "05210059"
            }
            let YBPatDivdata = await INSUYBUtil.insuYBAHSYB("InsuIPPayRefund", dllInputdata, newdllPath, "ReadYBSFZCard/INSUYBPAY.dll");
            let res = JSON.parse(YBPatDivdata);
            if (res.errorCode != '0') {
                message.warn(res.errorMessage);
                return
            }
        }
        var data = {
            params: [{
                "patBillID": this.state.patBillID || '', //就诊ID,
                "recordID": this.state.recordID || '', //就诊ID,
                "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id,
                "locID": JSON.parse(window.sessionStorage.userData).locID,//登录科室,
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4, 				//IP
            }],
        }

        $http.post('urlS', this, {
            code: "05300022",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {

                    // Keup.ModalMessage(3, this, res.errorMessage, '关闭', 'destroy', "现在就去", 'success')
                }
                else {
                    message.error(res.errorMessage)
                }
            }
        });
    }
    onChangeINSURegisterVisable() {
        if (!this.state.admID || this.state.admID === '') {
            message.error('请先选择就诊信息')
            return false
        }
        if (this.state.recordData.payStatusCode != "OB") {
            message.error('此记录不是未结算状态，不能登记')
            return false
        }
        this.setState({
            INSURegisterVisable: true,
        })
        this.child.resetFields()
        this.child.showModal()
        this.child.readYBPatdata(this.state.admID, this.state.userInfo)
    }
    // 调用子组件的连接事件
    onRef = (ref) => {
        this.child = ref
    }
    // 取消结算
    Cancellation = async () => {
        let openModal = Modal.info({
            title: "正在退费，请稍后......",
            content: <Spin size="large" />,
            onOk() { },
        });
        let errorCode = '0'
        let { recordData } = this.state
        let ipInsuType = recordData.ipInsuType
        ///判断付款记录是否是医保记录
        var paramsdata = {
            params: [{
                "billID": this.state.patBillID, //付款记录串
                "invtype": "PAY",   //his交易流水
                "userID": JSON.parse(window.sessionStorage.userData).userID || '', //操作人
                "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4, //ip
                "hospID": JSON.parse(window.sessionStorage.userData).hospID || '', //医院
            }]
        }
        let hisdataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210047");    //调用his接口
        if (hisdataobj.errorCode != '0') {
            message.warn(res.errorMessage);
            return
        }
        var insuPayID = hisdataobj.insuPayIDinfo
        if (insuPayID != "") {
            ///医保退费
            let insudata = {
                "params": [{
                    "admID": this.state.admID,
                    "userID": JSON.parse(window.sessionStorage.userData).userID,
                    "insuPayID": insuPayID,
                    "hospID": JSON.parse(window.sessionStorage.userData).hospID,
                    "patID": this.state.userInfo.patID || '',  //病人id
                    "readCardType": 'numble',            //this.state.readCardType
                    "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id,
                    "locID": JSON.parse(window.sessionStorage.userData).locID,//登录科室,
                    "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4,
                    "mac": JSON.parse(window.sessionStorage.ipConfig).mac

                }],
            }
            let res = await INSUYBUtil.GoTOHISHttp(insudata, "05020015");    //调用his接口
            //let YBPatDivdata = await INSUYBUtil.insuYBAHSYB("InsuIPPayRefund", dllInputdata,"ReadYBSFZCard/INSUYBPAY.dll");
            //let res = JSON.parse(YBPatDivdata);
            if (res.errorCode != '0') {
                message.warn(res.errorMessage);
                return
            }
        }
        if (errorCode === '0') {
            var data = {
                params: [{
                    "billID": this.state.patBillID || '', //就诊ID,
                    "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
                    "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id,
                    "locID": JSON.parse(window.sessionStorage.userData).locID,//登录科室,
                    "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                    "ip": JSON.parse(window.sessionStorage.ipConfig).ipv4, 				//IP
                }]
            }
            $http.post('urlS', this, {
                code: "05300023",
                data: data,
                success: function (res) {
                    let errorCode = res.errorCode;
                    if (errorCode === '0') {
                        this.dataTableTopData();
                        //if (!Util.isEmpty(this.state.source) && !Util.isEmpty(this.state.source.fphm)) {
                        //    this.handleDelPrint()
                        //}
                    }
                }
            });
        }
        openModal.destroy() //关闭等待界面
    }

    //金税作废发票
    handleDelPrint() {
        let that = this
        var data = {
            'fpzl': 2,
            'fphm': this.state.source ? this.state.source.fphm : '',//金税发票号码
            'fpdm': this.state.source ? this.state.source.fpdm : '',//金税发票代码
        }
        var source = encodeURIComponent(JSON.stringify(data))
        var dllInput = 'SID=4\&\&\&\SIDParam=' + source//JSON.stringify({ "SID": "0", "SIDParam": source })
        if (typeof (CefSharp) != "undefined") {   // 新元素定制浏览器
            // dllInput.path = "1";
            CefSharp.BindObjectAsync("xysCefToJavaScripts");
            setTimeout(() => {
                xysCefToJavaScripts.driveLocalHardware(JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput })).then((returnVale) => {
                    var res = JSON.parse(returnVale);
                    if (res.resultCode == '0') {
                        message.success('作废成功！')
                    }
                })
            }, 100);
        } else {
            $.getJSON("http://127.0.0.1:62534/XYSWCFService/DynamicLoadingDLL?JsonCallback=?", {
                input: JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput })
            },
                function (data) {
                    var res = JSON.parse(data);
                    if (res.resultCode == '0') {
                        message.success('作废成功！')
                    }
                    // alert(vData);
                });
        }
    }

    // 右键菜单事件
    handleContextMenu = (record, event) => {
        if (this.root)
            event.preventDefault()
        this.onClickRowPublicTop(record)
        this.setState({ contextMenuvisible: true })

        // clientX/Y 获取到的是触发点相对于浏览器可视区域左上角距离
        const clickX = event.clientX
        const clickY = event.clientY
        // window.innerWidth/innerHeight 获取的是当前浏览器窗口的视口宽度/高度
        const screenW = window.innerWidth
        const screenH = window.innerHeight
        // 获取自定义菜单的宽度/高度
        const rootW = this.root.offsetWidth
        const rootH = this.root.offsetHeight

        // right为true，说明鼠标点击的位置到浏览器的右边界的宽度可以放下菜单。否则，菜单放到左边。
        // bottom为true，说明鼠标点击位置到浏览器的下边界的高度可以放下菜单。否则，菜单放到上边。
        const right = (screenW - clickX) > rootW
        const left = !right
        const bottom = (screenH - clickY) > rootH
        const top = !bottom

        if (right) {
            this.root.style.left = `${clickX}px`
        }

        if (left) {
            this.root.style.left = `${clickX - rootW}px`
        }

        if (bottom) {
            this.root.style.top = `${clickY}px`
        }
        if (top) {
            this.root.style.top = `${clickY - rootH}px`
        }
    };
    //治疗方式
    xnhtreatment = async () => {
        try {
            if (((this.state.xnhjgCode !== '') && (this.state.recordData.admReasonCode != 'INSUHFSYB')) || (this.state.recordData.admReasonCode == 'INSUHFSYB')) {
                var paramsdata = {
                    params: [{
                        "insuAdmID": this.state.insuAdmID,
                        "userID": JSON.parse(window.sessionStorage.userData).userID || '',
                        "locID": JSON.parse(window.sessionStorage.userData).locID,
                        "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                        "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                        "xnhjgCode": (this.state.xnhjgCode),			//
                        "reasonCode": this.state.recordData.admReasonCode,
                    }]
                }
                let YBPatDataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210064");    //调用his接口
                if (YBPatDataobj.errorCode == '0') {
                    let xnhtreatCodeist = YBPatDataobj.xnhtreatCodeist;
                    this.setState({
                        xnhtreatCodeist: xnhtreatCodeist,
                    });
                }
                else {
                    message.warn(res.errorMessage);
                }
            }
        } catch (error) {
            message.warning("异常:" + error)
        }
    }
    xnhtreatCodeistChange = (val) => {
        this.setState({
            treatCode: val,
            icdAllNo: '',
            INSUICDDesc: ''
        });

        // setTimeout(() => {
        //     this.xnhtreatmentICD();
        // }, 10);
    }
    //治疗方式ICD诊断
    xnhtreatmentICD = async () => {
        try {
            if (this.state.xnhjgCode !== '') {
                var paramsdata = {
                    params: [{
                        "insuAdmID": this.state.insuAdmID,
                        "userID": JSON.parse(window.sessionStorage.userData).userID || '',
                        "locID": JSON.parse(window.sessionStorage.userData).locID,
                        "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                        "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                        "xnhjgCode": (this.state.xnhjgCode),			//
                        "treatCode": (this.state.treatCode),			//
                    }]
                }
                let YBPatDataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210068");    //调用his接口
                if (YBPatDataobj.errorCode == '0') {
                    let icdAllNoEList = YBPatDataobj.icdAllNoEList;
                    this.setState({
                        icdAllNoEList: icdAllNoEList,
                    });
                }
                else {
                    message.warn(res.errorMessage);
                }
            }
        } catch (error) {
            message.warning("异常:" + error)
        }
    }
    icdAllNoEListChange = (e) => {
        this.setState({ icdAllNo: e });
    }
    isEditing = record => record.key === this.state.editingKey;

    handleTableCancel = (record) => {
        let status = Util.checkAttributeIsEmpty(this.props.form.getFieldsValue());
        if (status) {
            // 都为空则删除该条记录
            this.setState({ editingKey: '' }, () => {
                this.handleDelete(record);
            })
        } else {
            this.setState({ editingKey: '' })
        }
    };

    // -- ICD诊断
    modalOnRef = (ref) => {
        this.modalChild = ref
    }
    // 诊断回车事件
    itmOnPressEnter = () => {
        let top = document.getElementById('inputDiag-id').getBoundingClientRect().top + 30 + 'px';
        let left = document.getElementById('inputDiag-id').getBoundingClientRect().left + 'px';
        this.setState({
            top,
            left,
            modalPage: 1
        });
        this.getModalListData(this.state.searchCode);
        //
    }
    itmOnChange = (e) => {
        if (!e.target.value) {
            this.setState({
                searchCode: '',
                INSUICDDesc: '',
                icdAllNo: ''
            })
        } else {
            this.setState({ searchCode: e.target.value })
        }
    }
    handleCompilePage = (page, pageSize) => {
        this.setState({ modalPageSize: pageSize, modalPage: page }, () => {
            this.getModalListData(this.state.searchCode);
        })
    }

    // 获取描述列表数据
    getModalListData(searchCode) {
        let { modalPageSize, modalPage, pageSize, page, admReasomID } = this.state;
        let data = {
            params: [
                {
                    insuAdmID: this.state.insuAdmID,
                    userID: JSON.parse(window.sessionStorage.userData).userID || '',
                    locID: JSON.parse(window.sessionStorage.userData).locID,
                    hospID: JSON.parse(window.sessionStorage.userData).hospID, //医院id
                    groupID: JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                    xnhjgCode: (this.state.xnhjgCode),			//
                    treatCode: (this.state.treatCode),			//
                    searchCode: searchCode,
                    reasonCode: this.state.recordData.admReasonCode
                }
            ],
            pagination: [{
                pageSize: modalPageSize,
                currentPage: modalPage,
                sortColumn: "Describe",
                sortOrder: "asc"
            }]
        }
        $http.post('urlS', this, {
            code: "05210068",
            data: data,
            success: function (res) {
                if (res.errorCode == '0') {
                    var source = res.result.data
                    for (var i = 0; i < source.length; i++) {
                        source[i].key = i + 1
                    }
                    this.setState({ icdAllNoEList: source, modalTotal: res.result.totalCount }, () => {
                        this.modalChild.showModal();
                    })
                } else {
                    this.setState({ icdAllNoEList: [], modalTotal: 0 })
                }
            }
        })
    }
    // 下拉table双击
    onClickRowPublic = (record) => {
        return {
            onDoubleClick: () => {
                this.setState({
                    icdAllNo: record.code,
                    INSUICDDesc: record.descripts,
                    searchCode: ''
                }, () => this.modalChild.handleCancel())
            }
        }

    }

    setRowClassNamePublic = () => {
        // return (record.id) === this.state.diagID ? 'clickRowStyl' : '';
    }

    handlePrintList() {
        let that = this
        var data = {
            'fpzl': 2,
            'fphm': this.state.source ? this.state.source.fphm : '',//金税发票号码
            'fpdm': this.state.source ? this.state.source.fpdm : '',//金税发票代码
            'showPrintDlg': 0
        }
        var source = encodeURIComponent(JSON.stringify(data))
        var dllInput = 'SID=3\&\&\&\SIDParam=' + source//JSON.stringify({ "SID": "0", "SIDParam": source })
        if (typeof (CefSharp) != "undefined") {   // 新元素定制浏览器
            // dllInput.path = "1";
            CefSharp.BindObjectAsync("xysCefToJavaScripts");
            setTimeout(() => {
                xysCefToJavaScripts.driveLocalHardware(JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput })).then((returnVale) => {
                    var res = JSON.parse(returnVale);
                    if (res.resultCode == '0') {
                        message.success('打印成功！')
                        // that.loadGoldTaxMessage()
                    }
                })
            }, 100);
        } else {
            $.getJSON("http://127.0.0.1:62534/XYSWCFService/DynamicLoadingDLL?JsonCallback=?", {
                input: JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput })
            },
                function (data) {
                    var res = JSON.parse(data);
                    if (res.resultCode == '0') {
                        message.success('打印成功！')
                        // that.loadGoldTaxMessage()
                    }
                    // alert(vData);
                });
        }
    }
    printSettlementList = () => {
        let { insuPayID, admReasonCode } = this.state;
        let data = {
            params: [
                {
                    insuPayID: insuPayID,
                    admReasonCode
                }
            ]
        }
        $http.post('urlS', this, {
            code: "05210079",
            data: data,
            success: function (res) {
                if (+res.errorCode === 0) {
                    $loopPrint('', res.result);
                }
            }
        })
    }

    //原号重打
    handlePrintReceive() {
           /**
         * @Byzxz:
         * Create 2022-11-118
         * 只有合肥普瑞走金税发票
         */
       if (JSON.parse(window.sessionStorage.userData).hospCode === 'H03') {
            let that = this
            var data = {
                'fpzl': 2,
                'fphm': this.state.fphm,//金税发票号码
                'fpdm': this.state.fpdm,//金税发票代码
                'showPrintDlg': 0
            }
            var source = encodeURIComponent(JSON.stringify(data))
            var dllInput = 'SID=2\&\&\&\SIDParam=' + source//JSON.stringify({ "SID": "0", "SIDParam": source })
            if (typeof (CefSharp) != "undefined") {   // 新元素定制浏览器
                // dllInput.path = "1";
                CefSharp.BindObjectAsync("xysCefToJavaScripts");
                setTimeout(() => {
                    xysCefToJavaScripts.driveLocalHardware(JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput })).then((returnVale) => {
                        var res = JSON.parse(returnVale);
                        if (res.resultCode == '0') {
                            message.success('打印成功！')
                            // that.loadGoldTaxMessage()
                        }
                    })
                }, 100);
            } else {
                $.getJSON("http://127.0.0.1:62534/XYSWCFService/DynamicLoadingDLL?JsonCallback=?", {
                    input: JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput })
                },
                    function (data) {
                        var res = JSON.parse(data);
                        if (res.resultCode == '0') {
                            message.success('打印成功！')
                            // that.loadGoldTaxMessage()
                        }
                        // alert(vData);
                    });
            }
        }else{
            this.print()
        }
    }

    onYbCardFlagChange = (e) => {
        this.setState({
            ybCardFlag: e.target.value,
        });
    }
    handleChangeSwitch(name, e) {
        this.setState({
            [name]: e ? 'Y' : 'N'
        })
    }
    // 就诊凭证类型
    certTypeonChange = (val, opt) => {
        this.setState({
            certType: val,
        });
    };
    // 就诊凭证编号
    certNoChange = e => {
        this.setState({ certNo: e.target.value })
    };
    handleChangeSwitch(name, e) {
        this.setState({
            [name]: e ? 'Y' : 'N'
        })
    }
    render() {
        // 组件所需参数
        const paramTop = {
            // 数据总条数
            total: this.state.totalTop,
            // 数据页数
            page: this.state.pageTop,
        };

        // 组件所需参数
        const param1 = {
            // 表头配置
            columns: this.state.columns1,
            // 表格数据
            data: this.state.dataTable1,
            // 数据总条数
            total: this.state.total1,
            // 数据页数
            page: this.state.page1,
        }

        const { userPayData, accSubStatus, language, modalTotal, modalPage, icdAllNoEList, top, left, } = this.state

        let rowSelection = {
            selectedRowKeys: this.state.selectedRowKeys,
            onChange: this.onSelectChange,
        };

        const components = {
            body: {
                cell: EditableCell,
            },
        };


        let operTypeDescOption = this.state.otherPayData && this.state.otherPayData.map((item, index) => {
            return (<Option title={item.paywDesc + '^' + item.paywCode} key={item.paywID} value={item.paywID}>{item.paywDesc}</Option>)
        })

        const filterColumns = this.state.ipPayWListTop.map(col => {
            if (!col.editable) {
                return col;
            }
            return {
                ...col,
                onCell: record => ({
                    record,
                    option: col.dataIndex === 'payWDesc' ? operTypeDescOption : "",
                    inputType: col.dataIndex === 'payWDesc' ? 'select' : 'text',
                    dataIndex: col.dataIndex,
                    title: col.title,
                    editing: this.isEditing(record),
                    source: {
                        paywselect: this.payWSelect,
                        paymoney: this.payMoney,
                        paymoneyonfocus: this.payMoneyonFocus,
                    }
                }),
            };
        });
        const addUSerInfo = (
            < div >
                <span style={{ marginRight: '20px' }}> 账户状态：<span style={{ color: '#007AFF', fontWeight: 'bold' }}>{accSubStatus.accSubStatusDesc || '正常'}</span></span>
                <span style={{ marginRight: '20px' }}> 本次就诊押金：<span style={{ color: '#007AFF', fontWeight: 'bold' }}>￥：{accSubStatus.admYJAmt || '0'}</span></span>
                <span style={{ marginRight: '20px' }}> 账户余额：<span style={{ color: '#007AFF', fontWeight: 'bold' }}>￥：{accSubStatus.accSubBlance || '0'}</span></span>
                <span style={{ marginRight: '20px' }}> 冻结金额：<span style={{ color: '#007AFF', fontWeight: 'bold' }}>￥：{accSubStatus.ipLockAccount || '0'}</span></span>
                <span style={{ marginRight: '20px' }}>可用金额：<span style={{ color: '#007AFF', fontWeight: 'bold' }}>￥：{accSubStatus.opBalance || '0'}</span></span>
            </div >
        )
        const contentPopover = (
            <div>
                <Table
                    className="smallTable"
                    pagination={false}
                    bordered
                    columns={this.columns2}
                    dataSource={this.state.dataTable2}
                    rowSelection={rowSelection}
                    scroll={{ y: 300, x: 700 }}
                    style={{ minHeight: '150px' }}
                />
            </div>
        );
        const modalParam = {
            width: '600px',
            total: modalTotal,
            page: modalPage,
            top: top,
            left: left,
            columns: this.modalColumns,
            data: icdAllNoEList,
            isOnRow: true,
            showPagination: true,
        }
        let { activeKey } = this.state
        return (
            <div style={{ background: '#F5F7FE', height: '100%', overflow: 'hidden' }} className='hospital-zation-express'>
                <ReadCard ref={r => this.readCard = r} />
                <Col span={4}>
                    <Row>
                        <Col span={24}>
                            <Card style={{ width: '100%', padding: '0' }} className='pd0'>
                                <div style={{ padding: 10 }}>
                                    {/* <Row className='mB10'> */}
                                    {/* <Col span={2}>
                                        <Select allowClear style={{ width: '100%', }} placeholder={language.DischargeSettlementVisitingward && language.DischargeSettlementVisitingward.message} value={this.state.cardType} onChange={(event) => { this.cardType(event) }}  >
                                            <Option value=''>{language.DischargeSettlementVisitingward && language.DischargeSettlementVisitingward.message}</Option>
                                            {this.state.cardTypeData.map(item => <Option title={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
                                        </Select>
                                    </Col>
                                    <Col span={4}>
                                        <Search className={`search ${!this.state.readModeI ? 'disabled' : ''}`} style={{ width: '100%', }} allowClear placeholder={language.DischargeSettlementCardnumber && language.DischargeSettlementCardnumber.message} disabled={this.state.disabledInput} value={this.state.cardNo} enterButton="读卡" onChange={(event) => { this.cardNo(event) }} onSearch={this.handleReadCard} />
                                    </Col> */}
                                    <Row className='mB10'>
                                        <Col span={24} >
                                            <Input.Group>
                                                <Select allowClear style={{ width: '30%', }} className='express-select-right' placeholder={language.DischargeSettlementVisitingward && language.DischargeSettlementVisitingward.message} value={this.state.cardType} onChange={(event) => { this.cardType(event) }}  >
                                                    <Option value=''>{language.DischargeSettlementVisitingward && language.DischargeSettlementVisitingward.message}</Option>
                                                    {this.state.cardTypeData.map(item => <Option title={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
                                                </Select>
                                                <Search className={`search ${!this.state.readModeI ? 'disabled' : ''}`} style={{ width: '69.9%', }} allowClear placeholder={language.DischargeSettlementCardnumber && language.DischargeSettlementCardnumber.message} disabled={this.state.disabledInput} value={this.state.cardNo} enterButton="读卡" onChange={(event) => { this.cardNo(event) }} onSearch={this.handleReadCard} />
                                            </Input.Group>
                                        </Col>
                                    </Row>
                                    <Row className='mB10'>
                                        <Col span={24}>
                                            <Input.Group>
                                                <Input className='express-input-disable' style={{ width: '30%', textAlign: 'center' }} value={language.DischargeSettlementPatientinformation && language.DischargeSettlementPatientinformation.descripts + '：'} disabled />
                                                <Input allowClear style={{ width: '69.9%', }} placeholder={language.DischargeSettlementPatientinformation && language.DischargeSettlementPatientinformation.message} className='input' value={this.state.patNo} onChange={(event) => { this.patNo(event) }} onKeyUp={(e) => { this.patNodownE(e, 'patNo'); }} />
                                            </Input.Group>
                                        </Col>
                                    </Row>
                                    <Row className='mB10'>
                                        <Col span={24} >
                                            <Input.Group>
                                                <Input className='express-input-disable' style={{ width: '30%', textAlign: 'center' }} value={language.DischargeSettlementInpatientNo && language.DischargeSettlementInpatientNo.descripts + '：'} disabled />
                                                <Input allowClear style={{ width: '69.9%' }} placeholder={language.DischargeSettlementInpatientNo && language.DischargeSettlementInpatientNo.message} className='input' />
                                            </Input.Group>
                                        </Col>
                                    </Row>
                                    <Row className='mB10'>
                                        <Col span={24} >
                                            <Input.Group>
                                                <Input className='express-input-disable' style={{ width: '30%', textAlign: 'center' }} value={language.DischargeSettlementChargeStatus && language.DischargeSettlementChargeStatus.descripts + '：'} disabled />
                                                <Select className='express-select-border' allowClear style={{ width: '69.9%' }} placeholder={language.DischargeSettlementChargeStatus && language.DischargeSettlementChargeStatus.message} value={this.state.chargeStatus} onChange={(event) => { this.chargeStatus(event) }}  >
                                                    <Option value='P'>已结算</Option>
                                                    <Option value='B'>未结算</Option>
                                                </Select>
                                            </Input.Group>
                                        </Col>
                                    </Row>
                                    <Row className='mB10'>
                                        <Col span={24} >
                                            <Input.Group>
                                                <Input className='express-input-disable' style={{ width: '30%', textAlign: 'center' }} value={language.DischargeSettlementSettlementtype && language.DischargeSettlementSettlementtype.descripts + '：'} disabled />
                                                <Select className='express-select-border' allowClear style={{ width: '69.9%' }} placeholder={language.DischargeSettlementVisitingward && language.DischargeSettlementVisitingward.message} value={this.state.jsType} onChange={(event) => { this.jsType(event) }}  >
                                                    <Option value=''>{language.DischargeSettlementVisitingward && language.DischargeSettlementVisitingward.message}</Option>
                                                    {this.state.jsTypeData.map(item => <Option title={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
                                                </Select>
                                            </Input.Group>
                                        </Col>
                                    </Row>
                                    <Row className='mB10'>
                                        <Col span={24} >
                                            <Input.Group>
                                                <Input className='express-input-disable' style={{ width: '30%', textAlign: 'center' }} value={language.DischargeSettlementVisitingward && language.DischargeSettlementVisitingward.descripts + '：'} disabled />
                                                <Select className='express-select-border' allowClear style={{ width: '69.9%' }} placeholder={language.DischargeSettlementVisitingward && language.DischargeSettlementVisitingward.message} value={this.state.bqType} onChange={(event) => { this.bqType(event) }}  >
                                                    <Option value=''>{language.DischargeSettlementVisitingward && language.DischargeSettlementVisitingward.message}</Option>
                                                    {this.state.bqData.map(item => <Option title={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
                                                </Select>
                                            </Input.Group>
                                        </Col>
                                    </Row>
                                    <Row className='mB10'>
                                        <Col span={25}>
                                            <Input.Group>
                                                <Input className='express-input-disable' style={{ width: '30%', textAlign: 'center' }} value={language.DischargeSettlementBednumber && language.DischargeSettlementBednumber.descripts + '：'} disabled />
                                                <Select className='express-select-border' allowClear showSearch style={{ width: '69.9%' }} placeholder={language.DischargeSettlementBednumber && language.DischargeSettlementBednumber.message} value={this.state.bednumber} onChange={(event) => { this.bednum(event) }}
                                                    filterOption={(input, options) => options.props.title.toLowerCase().indexOf(input.toLowerCase()) >= 0} onSelect={this.Selectbednum}>
                                                    {this.state.bedData.map(item => <Option title={item.bedDesc} key={item.bedCBID} value={item.bedCBID}  >{item.bedDesc}</Option>)}
                                                </Select>
                                            </Input.Group>
                                        </Col>
                                    </Row>
                                    <Row className='mB10'>
                                        <Col span={24} >
                                            <Input.Group style={{ display: 'flex' }}>
                                                <Input className='express-input-disable' style={{ width: '30%', textAlign: 'center' }} value={'类型' + '：'} disabled />
                                                <Select className='express-select-right' style={{ width: '69.9%' }} allowClear placeholder="请选择时间" value={this.state.time1} onChange={(event) => { this.time1(event) }}  >
                                                    <Option value='1'>在院</Option>
                                                    <Option value='2'>已出院</Option>
                                                </Select>
                                            </Input.Group>
                                        </Col>
                                    </Row>
                                    {this.state.time1 != 1 ? <Row className='mB10'>
                                        <Col span={24} >
                                            <Input.Group style={{ display: 'flex' }}>
                                                <div><RangeDatePicker className='express-select-border' format='YYYY-MM-DD' style={{ width: '100%' }}
                                                    startChange={this.startChange.bind(this)} endChange={this.endChange.bind(this)} /></div>
                                            </Input.Group>
                                        </Col>
                                    </Row> : ''}

                                    <Row style={{ marginTop: 5 }}>
                                        <Col span={10} style={{ marginLeft: 5 }}>
                                            <Button style={{ marginLeft: '10px' }} onClick={() => this.clearn()}>{language.DischargeSettlementempty && language.DischargeSettlementempty.descripts}</Button>
                                        </Col>
                                        <Col span={11} style={{ marginLeft: 5 }}>
                                            <Button type='primary' style={{ marginLeft: '20px' }} onClick={() => this.dataTableTopData()} >{language.DischargeSettlementquery && language.DischargeSettlementquery.descripts}</Button>
                                        </Col>
                                    </Row>
                                </div>
                            </Card>
                        </Col>
                    </Row>
                </Col>
                <Col span={20}>
                    <Row>
                        <Col>
                            <div className='dischange-tabs-body'>
                                <Card>
                                    <Tabs onChange={this.callback} activeKey={activeKey} type="card" size="small">
                                        <TabPane tab="出院结算" key="0" >
                                            <Col>
                                                <Card style={{ width: '100%', padding: '0', marginTop: 5 }} className='pd0' >
                                                    <div style={{ padding: 5, }} >
                                                        <Table
                                                            pagination={false}
                                                            bordered
                                                            scroll={{ y: (store.getState().tableHeight.y) - 320, x: 1100 }}
                                                            //scroll={{ y: 260, x: 1100 }}
                                                            columns={this.state.columnsTop}
                                                            dataSource={this.state.dataTableTop}
                                                            // style={{ minHeight: (store.getState().tableHeight.y) - 300 + 'px' }}
                                                            style={{ minHeight: 260 }}
                                                            onRow={(record) => {
                                                                return {
                                                                    onClick: (event) => {
                                                                        this.onClickRowPublicTop(record)
                                                                    },
                                                                    onContextMenu: (event) => {
                                                                        this.handleContextMenu(record, event);            //选中行右键
                                                                    },
                                                                };
                                                            }}
                                                            rowClassName={(record) => this.setRowClassNamePublicTop(record)}
                                                        />
                                                        <ColumnAuthoritysModel
                                                            clientWidth='900px'
                                                            compontName={this.state.ColumnAuthority}
                                                            configType="C"
                                                            onRef={this.onColumnRef}
                                                            reloadData={() => {
                                                                this.tableList(this.state.ColumnAuthority, this.state.ColumnAuthority)
                                                            }}
                                                        />
                                                        <CommonPagination size="large" current={paramTop.page} total={paramTop.total} search='search' pageSize='100'
                                                            onShowSizeChange={this.onShowSizeChangeTop.bind(this)} complete={false} dataSource={this.state.dataTableTop}
                                                            onChange={this.onChangeTop.bind(this)} />
                                                    </div>
                                                </Card>
                                            </Col>
                                            <Col span={24} style={{ marginTop: 5 }}>
                                                <div>
                                                    <div style={{ float: 'left', width: '13.7%' }}>
                                                        <Card style={{ height: (store.getState().tableHeight.y) - 145 }}>

                                                            <div>
                                                                <div style={{ textAlign: 'center' }}>
                                                                    {
                                                                        <div className={this.state.userInfo && this.state.userInfo.patSexCode == '1' ?
                                                                            'splice-boys' : (this.state.userInfo && this.state.userInfo.patSexCode == '2' ? 'splice-girls' : 'splice-girls')}></div>
                                                                    }
                                                                </div>
                                                                <div style={{ fontSize: '14px' }}>
                                                                    <div style={{ padding: '0 0 0 30px' }}>
                                                                        <div style={{ color: '#333333', fontWeight: 'bold' }}>
                                                                            <img src={icon_name} style={{ marginRight: 20, marginBottom: 3 }} />
                                                                            <span>{this.state.userInfo ? this.state.userInfo.patName || '--' : '--'}</span></div>

                                                                        <div style={{ marginTop: 10 }}><img src={icon_gender} style={{ marginRight: 20, marginBottom: 3 }} />
                                                                            {this.state.userInfo ? this.state.userInfo.patSexDesc || '--' : '--'}</div>

                                                                        <div style={{ marginTop: 10 }}><img src={icon_expense} style={{ marginRight: 20, marginBottom: 3 }} />
                                                                            {this.state.userInfo ? this.state.userInfo.patAge || '--' : '--'}</div>

                                                                        <div style={{ marginTop: 10 }}><img src={icon_icon} style={{ marginRight: 20, marginBottom: 3 }} />
                                                                            {this.state.userInfo ? this.state.userInfo.patMobile || '--' : '--'}</div>

                                                                        <div style={{ marginTop: 10 }}><Icon className='statusdesc-splice' style={{ marginRight: 20 }} />
                                                                            {this.state.userInfo ? this.state.userInfo.patSocialStatusDesc || '--' : '--'}</div>

                                                                        <div style={{ marginTop: 10 }}><Icon className='typeDesc-splice' style={{ marginRight: 20 }} />
                                                                            {this.state.userInfo ? this.state.userInfo.patTypeDesc || '--' : '--'}</div>

                                                                        <div style={{ color: '#007AFF', marginTop: 10, marginBottom: 10 }}><Icon className='account-splice' style={{ marginRight: 20 }} />
                                                                            {this.state.userInfo ? this.state.userInfo.accountBalance || '--' : 0}</div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </Card>
                                                    </div>
                                                    <div style={{ float: 'right', width: '86%' }}>
                                                        <Card style={{ width: '100%', padding: '0', height: (store.getState().tableHeight.y) - 145 }} className='pd0'>
                                                            <div>
                                                                <Row >
                                                                    <Col span={22}>
                                                                        <Card >
                                                                            <Row >
                                                                                <Col span={20} offset={1} style={{ textAlign: 'center', paddingTop: '5px' }}>
                                                                                    <h1>{((userPayData && userPayData.hospProvince) ? userPayData.hospProvince : '') + (language.DischargeSettlementHospitalizationProvince && language.DischargeSettlementHospitalizationProvince.descripts)}</h1>
                                                                                    <Row style={{ textAlign: 'left' }}>
                                                                                        <p><span><span className='greenSpan'>{language.DischargeSettlementChargingunit && language.DischargeSettlementChargingunit.descripts}：</span>{userPayData.chargeHosp}</span></p>
                                                                                        <p><span><span className='greenSpan'>{language.DischargeSettlementInpatientdepartment && language.DischargeSettlementInpatientdepartment.descripts}：</span>{userPayData.admLocDesc}</span><span><span className='greenSpan'>{language.DischargeSettlementSocialnumber && language.DischargeSettlementSocialnumber.descripts}：</span>{userPayData.insuCredNo}</span></p>
                                                                                        <p><span><span className='greenSpan'>{language.DischargeSettlementFullname && language.DischargeSettlementFullname.descripts}：</span>{userPayData.patName}</span><span><span className='greenSpan'>{language.DischargeSettlementGender && language.DischargeSettlementGender.descripts}：</span>{userPayData.patSexDesc}</span><span><span className='greenSpan'>{language.DischargeSettlementAge && language.DischargeSettlementAge.descripts}：</span>{userPayData.patAge}</span><span><span className='greenSpan'>{language.DischargeSettlementHospitalizationnumber && language.DischargeSettlementHospitalizationnumber.descripts}：</span>{userPayData.patNo}</span><span><span className='greenSpan'></span><span className='greenSpan'>{language.DischargeSettlementSettlingtime && language.DischargeSettlementSettlingtime.descripts}：</span>{userPayData.payDate}</span> <span><span className='greenSpan'>{language.DischargeSettlementTypesnsurance && language.DischargeSettlementTypesnsurance.descripts}：</span>{userPayData.payReasonDesc}</span></p>
                                                                                        <Divider />
                                                                                        <p><span><span className='greenSpan'>{language.DischargeSettlementAdmissiontime && language.DischargeSettlementAdmissiontime.descripts}：</span>{userPayData.admDate}  {userPayData.admTime}</span><span><span className='greenSpan'>{language.DischargeSettlementDischargetime && language.DischargeSettlementDischargetime.descripts}：</span>{userPayData.nurseChargeDate}  {userPayData.nurseChargeTime}</span><span><span className='greenSpan'>{language.DischargeSettlementTotalAStay && language.DischargeSettlementTotalAStay.descripts}：</span>{userPayData.ipDays}</span></p>
                                                                                        <Divider />
                                                                                        <ul>
                                                                                            {this.state.subTypeFeeArr.map((item, i) => {
                                                                                                return <span key={i} style={{ listStyleType: 'none', marginLeft: '10px' }}>{item + '；'}</span>
                                                                                            })}
                                                                                        </ul>
                                                                                        <Divider />
                                                                                        <p><span><span className='greenSpan'>{language.DischargeSettlementTotalamount && language.DischargeSettlementTotalamount.descripts}：</span>{userPayData.patBillPatAmt}</span></p>
                                                                                        <Divider />
                                                                                        <p><span><span className='greenSpan'>{language.DischargeSettlementTollcollector && language.DischargeSettlementTollcollector.descripts}：</span>{userPayData.userDesc}</span></p>
                                                                                    </Row>
                                                                                </Col>
                                                                            </Row>
                                                                        </Card>
                                                                    </Col>
                                                                    <Col span={2}>
                                                                        <Card style={{ padding: 5 }}>
                                                                            <Button className='buttonBox' onClick={() => this.clearnUserPayData()} disabled={this.state.disBtton1}  >
                                                                                <span><Icon type="rest" theme="filled" style={{ color: '#F5222D', fontSize: '20px' }} /></span>
                                                                                <span style={{ marginLeft: 5 }}>{language.DischargeSettlementempty && language.DischargeSettlementempty.descripts}</span>
                                                                            </Button>
                                                                            {/*disBtton2 试算 disBtton3 取消试算*/
                                                                                /*<Button className='buttonBox bkb' onClick={() => this.budgetAndSettlement()} disabled={this.state.disBtton2}>
                                                                                    <span><Icon type="calculator" theme="filled" style={{ color: '#FA541C', fontSize: '20px' }} /></span>
                                                                                    <span style={{marginLeft:5}}>{language.DischargeSettlementtrial && language.DischargeSettlementtrial.descripts}</span>
                                                                                </Button>
                                                                                <Button className='buttonBox bkb' onClick={() => this.Cancellationoftrialcalculation()} disabled={this.state.disBtton3}  >
                                                                                    <span><Icon type="calculator" theme="filled" style={{ color: '#FAAD14', fontSize: '20px' }} /></span>
                                                                                    <span style={{marginLeft:5}}>{language.DischargeSettlementCancellationcalculation && language.DischargeSettlementCancellationcalculation.descripts}</span>
                                                                                </Button>*/}
                                                                            <Button className='buttonBox bkb' onClick={() => this.Settlement()} disabled={this.state.disBtton4 || this.state.disBtn || Util.isEmpty(userPayData.nurseChargeDate)}>
                                                                                <span><Icon type="file-done" style={{ color: '#13C2C2', fontSize: '20px' }} /></span>
                                                                                <span style={{ marginLeft: 5 }}>{language.DischargeSettlementSettlement && language.DischargeSettlementSettlement.descripts}</span>
                                                                            </Button>
                                                                            <Button className='buttonBox bkb' onClick={() => this.Cancellation()} disabled={this.state.disBtton5}>
                                                                                <span><Icon type="file-sync" style={{ color: '#1890FF', fontSize: '20px' }} /></span>
                                                                                <span style={{ marginLeft: 5 }}>{language.DischargeSettlementCancellationSettlement && language.DischargeSettlementCancellationSettlement.descripts}</span>
                                                                            </Button>
                                                                            <Button className='buttonBox bkb' onClick={this.SplitTheBill} disabled={this.state.disBtton6}>
                                                                                <span><Icon type="tags" theme="filled" style={{ color: '#FA8C16', fontSize: '20px' }} /></span>
                                                                                <span style={{ marginLeft: 5 }}>{language.DischargeSettlementSplitbill && language.DischargeSettlementSplitbill.descripts}</span>
                                                                            </Button>
                                                                            <Button className='buttonBox bkb' onClick={() => this.ListOfHospitalizationExpenses()} disabled={this.state.disBtton7}>
                                                                                <span><Icon type="account-book" theme="filled" style={{ color: '#06B66E', fontSize: '20px' }} /></span>
                                                                                <span style={{ marginLeft: 5 }}>{language.DischargeSettlementCostlist && language.DischargeSettlementCostlist.descripts}</span>
                                                                            </Button>
                                                                            <Button className='buttonBox bkb' onClick={this.handlePrintList.bind(this)} disabled={this.state.disBtton7 ||
                                                                                Util.isEmpty(this.state.fphm)}>
                                                                                <span><Icon type="container" theme="filled" style={{ color: '#13C2C2', fontSize: '20px' }} /></span>
                                                                                <span style={{ marginLeft: 5 }}>发票清单<br />打印</span>
                                                                            </Button>
                                                                            <Button className='buttonBox bkb' onClick={this.printSettlementList} disabled={this.state.recordData.ipInsuType != 'Y' || !this.state.recordData.insuPayID ? true : false}>
                                                                                <span><Icon type="container" theme="filled" style={{ color: '#13C2C2', fontSize: '20px' }} /></span>
                                                                                <span style={{ marginLeft: 5 }}>结算单<br />打印</span>
                                                                            </Button>
                                                                            <Button className='buttonBox bkb' onClick={this.handlePrintReceive.bind(this)} disabled={this.state.disBtton7 ||
                                                                                Util.isEmpty(this.state.fphm)}>
                                                                                <span><Icon type="printer" theme="filled" style={{ color: '#13C2C2', fontSize: '20px' }} /></span>
                                                                                <span style={{ marginLeft: 5 }}>原号重打</span>
                                                                            </Button>
                                                                        </Card>
                                                                    </Col>
                                                                </Row>
                                                            </div>
                                                        </Card>
                                                    </div>
                                                </div>
                                            </Col>
                                        </TabPane>
                                        <TabPane tab="医保登记" key="1">
                                        </TabPane>
                                        <TabPane tab="住院押金" key="2" >
                                            {this.state.activeKey == '2' ? <PatientAccountManagement typeCinFlage="I"
                                                onRef={this.onPatAccManagement}
                                                key={this.props.form.getFieldValue('number') ? this.props.form.getFieldValue('number') : this.state.recordData.patNo}
                                                number={this.props.form.getFieldValue('number') ? this.props.form.getFieldValue('number') : this.state.recordData.patNo}
                                            ></PatientAccountManagement> : null}
                                        </TabPane>
                                    </Tabs>
                                </Card>
                            </div>
                        </Col>
                    </Row>
                </Col>
                <Modal
                    visible={this.state.visibleMoney}
                    onCancel={this.handleCancel}
                    onOk={this.handleCancel}
                    width='1300px'
                    title={language.DischargeSettlementCostlist && language.DischargeSettlementCostlist.descripts}
                >
                    <ListOfHospitalizationExpenses key={this.state.patBillID} patBillID={this.state.patBillID} userInfo={this.state.userInfo} />
                </Modal>
                <Modal
                    visible={this.state.visibleMoney2}
                    onCancel={this.handleCancel}
                    onOk={this.handleCancel}
                    width='1300px'
                    title={language.DischargeSettlementSplitbill && language.DischargeSettlementSplitbill.descripts}
                >
                    <SplitBills key={this.state.patBillID} paras={this.state.paras} />
                </Modal>
                <Modal
                    visible={this.state.visible}
                    onCancel={this.handleCancelMoney}
                    width='1300px'
                    title={
                        <div>
                            {language.DischargeSettlementSettlement && language.DischargeSettlementSettlement.descripts}
                            <span className='greenSpan'>{' ' + userPayData.patName + ' ( ' + userPayData.patNo + ' ) 结算类型:' + userPayData.payReasonDesc + '  入院日期:' + ' ' + userPayData.admDate + ' ' + userPayData.admTime + '  出院日期:' + userPayData.nurseChargeDate + ' ' + userPayData.nurseChargeTime}</span>
                        </div>
                    }
                    footer={
                        <div>
                            <Button type="danger" onClick={this.handleCancelMoney}>取消</Button>
                            <Button ref={this.refHandleOK} type="primary" onClick={this.handleVerfiyOk}>结算</Button>
                        </div>
                    }
                >
                    <div>
                        {this.state.paywamtData && this.state.paywamtData.length > 0 ? <Row>
                            已支付方式信息：
                            <Row className="ybpat-row">
                                {this.state.paywamtData.map((item, index) => {
                                    return <Row><Col className="ybpat-col" span={8} key={index} offset={4}>
                                        <p><i className="f1"></i>{item.desc}：</p><p className='p2'>￥<span>{item.value}</span></p>
                                    </Col></Row>
                                })}
                            </Row>
                        </Row> : ""}
                        <Row style={{ borderTop: "1px solid #ccc" }}>
                            <Col span={8} offset={4}>
                                <div className='payBox'>
                                    <p><i className="f1"></i>本次医疗费用</p>
                                    <p className='p2'>￥<span>{this.state.patAmt || '0.00'}</span></p>
                                </div>
                            </Col>
                            <Col span={8} offset={2}>
                                <div className='payBox'>
                                    <p><i className="f1"></i>剩余应收</p>
                                    <p className='p2'>￥<span>{this.state.leftAmt || '0.00'}</span></p>
                                </div>
                            </Col>
                        </Row>
                        <Row className='mT10'>
                            <Col span={12}>
                                <Row className='mT10'>
                                    <Col span={8} className='modalLabel ' style={{ textAlign: 'right' }}>住院账户余额：</Col>
                                    <Col span={16} >
                                        <Input disabled className='input' addonBefore="￥" value={this.state.accAmtBalance} onBlur={(event) => { if (event.target.value === '') { event.target.value = '0.00' } }} />
                                    </Col>
                                </Row>
                            </Col>
                            <Col span={12}>
                                <Row className='mT10'>
                                    <Col span={8} className='modalLabel' style={{ textAlign: 'right' }}>对冲金额：</Col>
                                    <Col span={16} >
                                        <Input disabled={this.state.sysConfigIP.PayAccIPAmtFlag && this.state.sysConfigIP.PayAccIPAmtFlag === 'N' ? false : true} ref={this.myRef6} style={{ width: '50%' }} addonBefore="￥" onChange={(e) => { this.onChangepayAccIPAmt(e); }} value={this.state.payAccIPAmt} onBlur={(event) => { if (event.target.value === '') { event.target.value = '0.00' } this.setState({ payAccIPAmt: parseFloat(event.target.value).toFixed(2) }) }} onFocus={(event) => { if (event.target.value === '0.00') { event.target.value = '' } }} onPressEnter={this.onPressEnter6} />
                                        <Input style={{ width: '50%' }} addonBefore="余" value={this.state.accpayBalance} onBlur={(event) => { if (event.target.value === '') { event.target.value = '0.00' } this.setState({ payAccIPAmt: parseFloat(event.target.value).toFixed(2) }) }} onFocus={(event) => { if (event.target.value === '0.00') { event.target.value = '' } }} />
                                    </Col>
                                </Row>
                            </Col>
                        </Row>
                        <Divider dashed style={{ margin: '12px' }} />
                        <Row>
                            <EditableContext.Provider value={this.props.form}>
                                <Table
                                    dataSource={this.state.payWListData}
                                    columns={filterColumns}
                                    components={components}
                                    pagination={false}
                                    onRow={this.ChangepayWonRow}
                                    bordered
                                    className="table-pay-list"
                                />
                            </EditableContext.Provider>
                            <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'flex-end' }}>
                                <div style={{ textAlign: "right", marginRight: '80px' }}>
                                    <p style={{ color: 'rgba(240,65,52,1)' }}><span>剩余余额：￥{parseFloat(this.state.surplusamt) === 0 ? '' : parseFloat(this.state.surplusamt)}</span></p>
                                </div>
                                <div style={{ textAlign: "right" }}>
                                    <Button icon="plus" onClick={this.handleAddTableData} style={{ background: 'rgba(247,128,93,1)', color: '#fff' }}>新增</Button>
                                </div>
                            </div>
                        </Row>
                        <Row className='mT10' style={{ display: this.state.disXJ ? 'block' : 'none', borderTop: "1px solid #ccc" }} >
                            <Divider dashed={true}>实收现金</Divider>
                            <Col span={24}>
                                <Row className="mT5">
                                    <Col span={5} className='modalLabel '>实收现金：</Col>
                                    <Col span={7} >
                                        <Input ref={this.myRef5} value={this.state.cashInCashVal} onChange={(e) => { this.cashInCash(e.target.value); }} className='input' addonBefore="￥" onBlur={(event) => { if (event.target.value === '') { event.target.value = '0.00' } this.setState({ cashInCashVal: parseFloat(event.target.value).toFixed(2) }) }} onFocus={(event) => { if ((event.target.value === '0.00') || (event.target.value === '0')) { event.target.value = '' } }} onPressEnter={() => { setTimeout(() => { this.refHandleOK.current.focus(); }, 1); }} />
                                    </Col>
                                    <Col span={5} className='modalLabel' ></Col>
                                    <Col span={7} >
                                        <p style={{ color: parseFloat(this.state.zeroPay) < 0 ? 'rgba(240,65,52,1)' : '' }}><span>找零（元）：￥{this.state.zeroPay}</span></p>
                                    </Col>
                                </Row>
                            </Col>
                        </Row>
                    </div>
                </Modal>
                <Modal
                    visible={this.state.modalShow}
                    title='设置发票号'
                    onCancel={this.handleCancel}
                    onOk={this.handleCancel}
                    width='600px'
                    footer={null}
                    destroyOnClose={true}
                >
                    {/* <HistoryModal userInfo={this.state.userInfo} updateParent={this.updateParent}></HistoryModal> */}
                    <HopNumber invTypeCode='I' key={this.state.invoice} handleCancel={this.handleCancel} handelThis={this} />

                </Modal>
                <Modal
                    visible={this.state.InsuIPPayModalvisible}
                    onCancel={this.handleCancelInsuIPPayModal}
                    width='1000px'
                    title='医保病人信息'
                    footer={
                        <div style={{ display: "flex", justifyContent: "center" }}>
                            <Button type="primary" onClick={() => this.InsuIPPrePay()} style={{ display: this.state.InsuIPPayButton === '2' ? 'block' : 'none' }}>医保预结算</Button>
                            <Button type="primary" onClick={() => this.handleCancelInsuIPPayModal()} style={{ display: this.state.InsuIPPayButton === '4' ? 'block' : 'none' }}>取消</Button>
                            <Button type="primary" onClick={() => this.InsuIPPrePay()} style={{ display: this.state.InsuIPPayButton === '4' ? 'block' : 'none' }}>确认结算</Button>
                            <Button type="primary" onClick={this.handleCancelInsuIPPayModal} style={{ display: this.state.InsuIPPayButton === '2' ? 'block' : 'none' }}>关闭</Button>
                        </div>
                    }
                >
                    <div>
                        <Row className="ybpat-row">
                            {this.state.YBPatDivdata.map((item, index) => {
                                return <Col className="ybpat-col" span={8} key={index}>
                                    <span className="ybpat-desc">{item.desc}</span>
                                    <span>：</span>
                                    <span className="ybpat-value">{item.value}</span>
                                </Col>
                            })}
                        </Row>
                        {this.state.ybPayDivdata && this.state.ybPayDivdata.length > 0 ? <Row style={{ borderTop: "1px solid #ccc" }}>
                            病人医保结算信息：
                            <Row className="ybpat-row">
                                {this.state.ybPayDivdata.map((item, index) => {
                                    return <Col className="ybpat-col" span={8} key={index}>
                                        <span className="ybpat-desc">{item.desc}</span>
                                        <span>：</span>
                                        <span className="ybpat-value">{item.value}</span>
                                    </Col>
                                })}
                            </Row>
                        </Row> : ""}
                        <Row style={{ borderTop: "1px solid #ccc" }}>
                            <Col className="ybpat-col" span={8} key={1}>
                                <div><span className="ybpat-desc">就诊凭证类型:</span>
                                    <span className="ybpat-value">
                                        <Select style={{ width: '150px', margin: '12px 15px 0 0' }} value={this.state.certType} onChange={this.certTypeonChange} >
                                            <Option value='01'>电子凭证令牌</Option>
                                            <Option value='02'>身份证号</Option>
                                            <Option value='03'>社会保障卡</Option>
                                        </Select>
                                    </span>
                                </div>
                            </Col>
                            <Col className="ybpat-col" span={8} key={1}>
                                <div><span className="ybpat-desc">就诊凭证编号:</span>
                                    <span className="ybpat-value">
                                        <Input style={{ width: '150px', margin: '12px 15px 0 0'}}  placeholder="" value={this.state.certNo} onChange={(e) => this.certNoChange(e)} onPressEnter={this.YBInputSure}></Input>
                                    </span>
                                </div>
                            </Col>
                            <Col className="ybpat-col" span={8} key={1}>
                                <div style={{margin: '18px 0 0 30px'}}><span className="ybpat-desc">中途结算标志:</span>
                                    <span className="ybpat-value">
                                        <Switch checkedChildren="是" unCheckedChildren="否" checked={this.state.middleSettleFlag == 'Y' ? true : false} onChange={this.handleChangeSwitch.bind(this, 'middleSettleFlag')} />
                                    </span>
                                </div>
                            </Col>
                        </Row>
                        <Row style={{ borderTop: "0px",marginTop:'10px',paddingTop:'10px'}}>
                            <Col className="ybpat-col" span={8} key={20}>
                                <div><span className="ybpat-desc">外伤标志</span>
                                    <span>：</span>
                                    <span className="ybpat-value">
                                        <Switch checkedChildren="是" unCheckedChildren="否" checked={this.state.traumaFlag === 'Y'}
                                                onChange={this.handleChangeSwitch.bind(this, 'traumaFlag')} />
                                    </span></div>
                            </Col>
                            <Col className="ybpat-col" span={8} key={21}>
                                <div><span className="ybpat-desc">涉及第三方标志</span>
                                    <span>：</span>
                                    <span className="ybpat-value">
                                        <Switch checkedChildren="是" unCheckedChildren="否" checked={this.state.thirdFlag === 'Y'}
                                                onChange={this.handleChangeSwitch.bind(this, 'thirdFlag')} />
                                    </span></div>
                            </Col>
                            <Col className="ybpat-col" span={8} key={22}>
                                <div><span className="ybpat-desc">住院类型</span>
                                    <span>：</span>
                                    <span className="ybpat-value">
                                        <Select style={{ width: '150px'}} value={this.state.insuMdHosType} onChange={this.insuMdHosTypeonChange}>
                                            {/*{this.state.insuMdHosTypeList && Array.isArray(this.state.insuMdHosTypeList) && this.state.insuMdHosTypeList.map((item, index) => <Option title={item.descripts} key={index} value={item.code} >{item.descripts}</Option>)}*/}
                                            <Option title='普通住院' key={1} value={1} >普通住院</Option>
                                            <Option title='急诊或抢救住院' key={2} value={2} >急诊或抢救住院</Option>
                                            <Option title='转院住院' key={3} value={3} >转院住院</Option>
										</Select>
                                    </span></div>
                            </Col>
                        </Row>
                        <Row>
                            <Col className="ybpat-col" span={8} key={1}>
                                <div style={{margin: '18px 0 0 0'}}><span className="ybpat-desc">使用账户标志:</span>
                                    <span className="ybpat-value">
                                        <Switch checkedChildren="是" unCheckedChildren="否" checked={this.state.userAccFlag == 'Y' ? true : false} onChange={this.handleChangeSwitch.bind(this, 'userAccFlag')} />
                                    </span>
                                </div>
                            </Col>
                        </Row>
                    </div>
                </Modal>
                <INSURegister
                    size="small"
                    onRef={this.onRef}
                    admID={this.state.admID}
                    admReasonCode={this.state.admReasonCode}
                />
                {/**列input框新表格弹框 */}
                <PublicModalTable
                    onClickRowPublic={this.onClickRowPublic}
                    setRowClassNamePublic={this.setRowClassNamePublic}
                    param={modalParam}
                    onRef={this.modalOnRef}
                    compilePage={this.handleCompilePage}
                />
                <IframeModal onRef={ref => this.iframeRef = ref} />
                <div ref={(ref) => { this.root = ref }} className="contextMenu-wrap" style={{ visibility: this.state.contextMenuvisible ? 'visible' : 'hidden' }}>
                    <div className="contextMenu-option" onClick={this.bill}>账单</div>
                    <div className="contextMenu-option" onClick={this.InsuUPloadItem}>医保费用上传</div>
                    <div className="contextMenu-option" onClick={this.CancleInsuUPloadItem}>撤销上传的医保费用</div>
                    <div className="contextMenu-option" onClick={() => this.InsuIPPayModal('2')}>医保试算</div>
                    <div className="contextMenu-option" onClick={() => this.unbudgetAndSettlement()}>取消预结算</div>
                    <div className="contextMenu-option" onClick={() => this.InsuRighting()}>医保结算冲正</div>
                    <div className="contextMenu-option" onClick={() => this.InsuIPRegRighting()}>医保登记冲正</div>
                </div>
            </div >


        )
    }
};

let DischargeSettlementForm = Form.create()(DischargeSettlement);
export default DischargeSettlementForm;
